MCPcopy
hub / github.com/rclone/rclone / cacheExpire

Method cacheExpire

lib/cache/cache.go:221–237  ·  view source on GitHub ↗

cacheExpire expires any entries that haven't been used recently

()

Source from the content-addressed store, hash-verified

219
220// cacheExpire expires any entries that haven't been used recently
221func (c *Cache) cacheExpire() {
222 c.mu.Lock()
223 defer c.mu.Unlock()
224 now := time.Now()
225 for key, entry := range c.cache {
226 if entry.pinCount <= 0 && now.Sub(entry.lastUsed) > c.expireDuration {
227 c.finalize(entry.value)
228 delete(c.cache, key)
229 }
230 }
231 if len(c.cache) != 0 {
232 time.AfterFunc(c.expireInterval, c.cacheExpire)
233 c.expireRunning = true
234 } else {
235 c.expireRunning = false
236 }
237}
238
239// Clear removes everything from the cache
240func (c *Cache) Clear() {

Callers 3

TestCacheExpireFunction · 0.80
TestCachePinFunction · 0.80
TestCacheFinalizeFunction · 0.80

Calls 3

finalizeMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 3

TestCacheExpireFunction · 0.64
TestCachePinFunction · 0.64
TestCacheFinalizeFunction · 0.64