RemoveOldest removes the oldest item from the cache.
()
| 198 | |
| 199 | // RemoveOldest removes the oldest item from the cache. |
| 200 | func (c *LRU[K, V]) RemoveOldest() (key K, value V, ok bool) { |
| 201 | c.mu.Lock() |
| 202 | defer c.mu.Unlock() |
| 203 | if ent := c.evictList.Back(); ent != nil { |
| 204 | c.removeElement(ent) |
| 205 | return ent.Key, ent.Value, true |
| 206 | } |
| 207 | return |
| 208 | } |
| 209 | |
| 210 | // GetOldest returns the oldest entry |
| 211 | func (c *LRU[K, V]) GetOldest() (key K, value V, ok bool) { |