Files
kopia/cli/command_cache_set.go
Jarek Kowalski bf311400f4 Added separate cache for metadata.
All blocks with a non-empty prefix land in that cache which has its own
size and expires independently from content cache.
2019-06-08 11:57:23 -07:00

33 lines
1.3 KiB
Go

package cli
import (
"context"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/content"
)
var (
cacheSetParamsCommand = cacheCommands.Command("set", "Sets parameters local caching of repository data")
cacheSetDirectory = cacheSetParamsCommand.Flag("cache-directory", "Directory where to store cache files").String()
cacheSetMaxCacheSizeMB = cacheSetParamsCommand.Flag("cache-size-mb", "Size of local content cache (0 disables caching)").PlaceHolder("MB").Int64()
cacheSetMaxMetadataCacheSizeMB = cacheSetParamsCommand.Flag("metadata-cache-size-mb", "Size of local metadata cache (0 disables caching)").PlaceHolder("MB").Int64()
cacheSetMaxListCacheDuration = cacheSetParamsCommand.Flag("max-list-cache-duration", "Duration of index cache").Default("600s").Duration()
)
func runCacheSetCommand(ctx context.Context, rep *repo.Repository) error {
opts := content.CachingOptions{
CacheDirectory: *cacheSetDirectory,
MaxCacheSizeBytes: *cacheSetMaxCacheSizeMB << 20,
MaxMetadataCacheSizeBytes: *cacheSetMaxMetadataCacheSizeMB << 20,
MaxListCacheDurationSec: int(cacheSetMaxListCacheDuration.Seconds()),
}
return repo.SetCachingConfig(ctx, repositoryConfigFileName(), opts)
}
func init() {
cacheSetParamsCommand.Action(repositoryAction(runCacheSetCommand))
}