MCPcopy
hub / github.com/go-gorm/gorm / Peek

Method Peek

internal/lru/lru.go:173–185  ·  view source on GitHub ↗

Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.

(key K)

Source from the content-addressed store, hash-verified

171// Peek returns the key value (or undefined if not found) without updating
172// the "recently used"-ness of the key.
173func (c *LRU[K, V]) Peek(key K) (value V, ok bool) {
174 c.mu.RLock()
175 defer c.mu.RUnlock()
176 var ent *Entry[K, V]
177 if ent, ok = c.items[key]; ok {
178 // Expired item check
179 if time.Now().After(ent.ExpiresAt) {
180 return value, false
181 }
182 return ent.Value, true
183 }
184 return
185}
186
187// Remove removes the provided key from the cache, returning if the
188// key was contained.

Callers 2

TestLRUNoPurgeFunction · 0.80
TestLoadingExpiredFunction · 0.80

Calls 1

AfterMethod · 0.45

Tested by 2

TestLRUNoPurgeFunction · 0.64
TestLoadingExpiredFunction · 0.64