Close destroys cleanup goroutine. To clean up the cache, run Purge() before Close(). func (c *LRU[K, V]) Close() { c.mu.Lock() defer c.mu.Unlock() select { case <-c.done: return default: } close(c.done) } removeOldest removes the oldest item from the cache. Has to be called with lock!
()
| 304 | |
| 305 | // removeOldest removes the oldest item from the cache. Has to be called with lock! |
| 306 | func (c *LRU[K, V]) removeOldest() { |
| 307 | if ent := c.evictList.Back(); ent != nil { |
| 308 | c.removeElement(ent) |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // removeElement is used to remove a given list element from the cache. Has to be called with lock! |
| 313 | func (c *LRU[K, V]) removeElement(e *Entry[K, V]) { |
no test coverage detected