Files
kopia/cli/command_cache_set.go
Jarek Kowalski 54edb97b3a refactoring: renamed repo/block to repo/content
Also introduced strongly typed content.ID and manifest.ID (instead of string)

This aligns identifiers across all layers of repository:

blob.ID
content.ID
object.ID
manifest.ID
2019-06-01 22:24:19 -07:00

31 lines
1.1 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 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,
MaxListCacheDurationSec: int(cacheSetMaxListCacheDuration.Seconds()),
}
return repo.SetCachingConfig(ctx, repositoryConfigFileName(), opts)
}
func init() {
cacheSetParamsCommand.Action(repositoryAction(runCacheSetCommand))
}