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

Method Get

internal/lru/lru.go:147–160  ·  view source on GitHub ↗

Get looks up a key's value from the cache.

(key K)

Source from the content-addressed store, hash-verified

145
146// Get looks up a key's value from the cache.
147func (c *LRU[K, V]) Get(key K) (value V, ok bool) {
148 c.mu.Lock()
149 defer c.mu.Unlock()
150 var ent *Entry[K, V]
151 if ent, ok = c.items[key]; ok {
152 // Expired item check
153 if time.Now().After(ent.ExpiresAt) {
154 return value, false
155 }
156 c.evictList.MoveToFront(ent)
157 return ent.Value, true
158 }
159 return
160}
161
162// Contains checks if a key is in the cache, without updating the recent-ness
163// or deleting it for being stale.

Callers

nothing calls this directly

Calls 2

MoveToFrontMethod · 0.80
AfterMethod · 0.45

Tested by

no test coverage detected