Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: implement rc.PutCachedFs for prefilling the remote cache

Nick Craig-Wood75e8ea383c40
diff --git a/fs/rc/cache.go b/fs/rc/cache.go
index af3aac230..dd9896ce3 100644
--- a/fs/rc/cache.go
+++ b/fs/rc/cache.go
@@ -48,6 +48,21 @@ func GetCachedFs(fsString string) (f fs.Fs, err error) {
return entry.f, err
}
+// PutCachedFs puts an fs.Fs named fsString into the cache
+func PutCachedFs(fsString string, f fs.Fs) {
+ fsCacheMu.Lock()
+ defer fsCacheMu.Unlock()
+ fsCache[fsString] = &cacheEntry{
+ f: f,
+ fsString: fsString,
+ lastUsed: time.Now(),
+ }
+ if !expireRunning {
+ time.AfterFunc(cacheExpireInterval, cacheExpire)
+ expireRunning = true
+ }
+}
+
// cacheExpire expires any entries that haven't been used recently
func cacheExpire() {
fsCacheMu.Lock()