mirror of
https://github.com/kopia/kopia.git
synced 2026-01-19 11:57:55 -05:00
31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/repo"
|
|
"github.com/kopia/repo/block"
|
|
)
|
|
|
|
var (
|
|
cacheSetParamsCommand = cacheCommands.Command("set", "Sets parameters local caching of repository data").Hidden()
|
|
|
|
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 := block.CachingOptions{
|
|
CacheDirectory: *cacheSetDirectory,
|
|
MaxCacheSizeBytes: *cacheSetMaxCacheSizeMB << 20,
|
|
MaxListCacheDurationSec: int(cacheSetMaxListCacheDuration.Seconds()),
|
|
}
|
|
|
|
return repo.SetCachingConfig(ctx, repositoryConfigFileName(), opts)
|
|
}
|
|
|
|
func init() {
|
|
cacheSetParamsCommand.Action(repositoryAction(runCacheSetCommand))
|
|
}
|