evictLRU removes the least recently used item from the cache
()
| 79 | |
| 80 | // evictLRU removes the least recently used item from the cache |
| 81 | func (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 |
| 91 | func (c *Cache) startEvictionTicker(d time.Duration) { |