MCPcopy Create free account
hub / github.com/PacktPublishing/System-Programming-Essentials-with-Go / evictLRU

Method evictLRU

ch13/cache.go:81–88  ·  view source on GitHub ↗

evictLRU removes the least recently used item from the cache

()

Source from the content-addressed store, hash-verified

79
80// evictLRU removes the least recently used item from the cache
81func (c *Cache) evictLRU() {
82 elem := c.eviction.Back()
83 if elem != nil {
84 c.eviction.Remove(elem)
85 kv := elem.Value.(*entry)
86 delete(c.items, kv.key)
87 }
88}
89
90// startEvictionTicker starts a background goroutine that periodically evicts expired items
91func (c *Cache) startEvictionTicker(d time.Duration) {

Callers 1

SetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected