From 1b2f2c0d69c026df0aa6e5d011e90400645c7b7a Mon Sep 17 00:00:00 2001 From: NickIAm Date: Fri, 24 Mar 2023 19:28:34 +0800 Subject: [PATCH] docs: add section about --vfs-cache-max-age This change adds a section to clarify how exactly the --vfs-cache-max-age flag affects caching --- vfs/help.go | 15 +++++++++++++-- vfs/vfsflags/vfsflags.go | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vfs/help.go b/vfs/help.go index 84ad2dc9d..fe3c5f2a9 100644 --- a/vfs/help.go +++ b/vfs/help.go @@ -86,7 +86,7 @@ find that you need one or the other or both. --cache-dir string Directory rclone will use for caching. --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) - --vfs-cache-max-age duration Max age of objects in the cache (default 1h0m0s) + --vfs-cache-max-age duration Max time since last access of objects in the cache (default 1h0m0s) --vfs-cache-max-size SizeSuffix Max total size of objects in the cache (default off) --vfs-cache-poll-interval duration Interval to poll the cache for stale objects (default 1m0s) --vfs-write-back duration Time to writeback files after last use when using cache (default 5s) @@ -109,7 +109,18 @@ flags. If using !--vfs-cache-max-size! note that the cache may exceed this size for two reasons. Firstly because it is only checked every !--vfs-cache-poll-interval!. Secondly because open files cannot be -evicted from the cache. +evicted from the cache. When !--vfs-cache-max-size! +is exceeded, rclone will attempt to evict the least accessed files +from the cache first. rclone will start with files that haven't +been accessed for the longest. This cache flushing strategy is +efficient and more relevant files are likely to remain cached. + +The !--vfs-cache-max-age! will evict files from the cache +after the set time since last access has passed. The default value of +1 hour will start evicting files from cache that haven't been accessed +for 1 hour. When a cached file is accessed the 1 hour timer is reset to 0 +and will wait for 1 more hour before evicting. Specify the time with +standard notation, s, m, h, d, w . You **should not** run two copies of rclone using the same VFS cache with the same or overlapping remotes if using !--vfs-cache-mode > off!. diff --git a/vfs/vfsflags/vfsflags.go b/vfs/vfsflags/vfsflags.go index ccdcb17db..b4682f785 100644 --- a/vfs/vfsflags/vfsflags.go +++ b/vfs/vfsflags/vfsflags.go @@ -26,7 +26,7 @@ func AddFlags(flagSet *pflag.FlagSet) { flags.BoolVarP(flagSet, &Opt.ReadOnly, "read-only", "", Opt.ReadOnly, "Only allow read-only access") flags.FVarP(flagSet, &Opt.CacheMode, "vfs-cache-mode", "", "Cache mode off|minimal|writes|full") flags.DurationVarP(flagSet, &Opt.CachePollInterval, "vfs-cache-poll-interval", "", Opt.CachePollInterval, "Interval to poll the cache for stale objects") - flags.DurationVarP(flagSet, &Opt.CacheMaxAge, "vfs-cache-max-age", "", Opt.CacheMaxAge, "Max age of objects in the cache") + flags.DurationVarP(flagSet, &Opt.CacheMaxAge, "vfs-cache-max-age", "", Opt.CacheMaxAge, "Max time since last access of objects in the cache") flags.FVarP(flagSet, &Opt.CacheMaxSize, "vfs-cache-max-size", "", "Max total size of objects in the cache") flags.FVarP(flagSet, &Opt.ChunkSize, "vfs-read-chunk-size", "", "Read the source objects in chunks") flags.FVarP(flagSet, &Opt.ChunkSizeLimit, "vfs-read-chunk-size-limit", "", "If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached ('off' is unlimited)")