- Sort Score
- Result 10 results
- Languages All
Results 1 - 3 of 3 for NewLRU (0.04 sec)
-
tests/lru_test.go
func TestLRU_Add_ExistingKey_UpdatesValueAndExpiresAt(t *testing.T) { lru := lru.NewLRU[string, int](10, nil, time.Hour) lru.Add("key1", 1) lru.Add("key1", 2) if value, ok := lru.Get("key1"); !ok || value != 2 { t.Errorf("Expected value to be updated to 2, got %v", value) } } func TestLRU_Add_NewKey_AddsEntry(t *testing.T) { lru := lru.NewLRU[string, int](10, nil, time.Hour) lru.Add("key1", 1)
Registered: Sun Sep 07 09:35:13 UTC 2025 - Last Modified: Sun May 25 07:40:40 UTC 2025 - 10.4K bytes - Viewed (0) -
internal/lru/lru.go
const numBuckets = 100 // NewLRU returns a new thread-safe cache with expirable entries. // // Size parameter set to 0 makes cache of unlimited size, e.g. turns LRU mechanism off. // // Providing 0 TTL turns expiring off. // // Delete expired entries every 1/100th of ttl value. Goroutine which deletes expired entries runs indefinitely.
Registered: Sun Sep 07 09:35:13 UTC 2025 - Last Modified: Fri Apr 25 08:22:26 UTC 2025 - 12.5K bytes - Viewed (0) -
internal/stmt_store/stmt_store.go
size = defaultMaxSize } if ttl <= 0 { ttl = defaultTTL } onEvicted := func(k string, v *Stmt) { if v != nil { go v.Close() } } return &lruStore{lru: lru.NewLRU[string, *Stmt](size, onEvicted, ttl)} } type lruStore struct { lru *lru.LRU[string, *Stmt] } func (s *lruStore) Keys() []string { return s.lru.Keys() }
Registered: Sun Sep 07 09:35:13 UTC 2025 - Last Modified: Sun Apr 27 06:05:16 UTC 2025 - 6K bytes - Viewed (0)