- Sort Score
- Result 10 results
- Languages All
Results 1 - 2 of 2 for removeOldest (0.52 sec)
-
internal/lru/lru.go
c.mu.Lock() defer c.mu.Unlock() if ent, ok := c.items[key]; ok { c.removeElement(ent) return true } return false } // RemoveOldest removes the oldest item from the cache. func (c *LRU[K, V]) RemoveOldest() (key K, value V, ok bool) { c.mu.Lock() defer c.mu.Unlock() if ent := c.evictList.Back(); ent != nil { c.removeElement(ent) return ent.Key, ent.Value, true }
Registered: Sun Sep 07 09:35:13 UTC 2025 - Last Modified: Fri Apr 25 08:22:26 UTC 2025 - 12.5K bytes - Viewed (0) -
tests/lru_test.go
} } func TestLRURemoveOldest(t *testing.T) { lc := lru.NewLRU[string, string](2, nil, 0) if lc.Cap() != 2 { t.Fatalf("expect cap is 2") } k, v, ok := lc.RemoveOldest() if k != "" { t.Fatalf("should be empty") } if v != "" { t.Fatalf("should be empty") } if ok { t.Fatalf("should be false") } ok = lc.Remove("non_existent") if ok {
Registered: Sun Sep 07 09:35:13 UTC 2025 - Last Modified: Sun May 25 07:40:40 UTC 2025 - 10.4K bytes - Viewed (0)