rc: implement rc.PutCachedFs for prefilling the remote cache

This commit is contained in:
Nick Craig-Wood
2018-11-04 20:42:57 +00:00
parent 8c8b58a7de
commit 75e8ea383c
+15
View File
@@ -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()