diff options
| author | 2026-03-06 04:43:03 +0800 | |
|---|---|---|
| committer | 2026-03-06 04:43:03 +0800 | |
| commit | fec8b64975f952e2fa5fa8478b09dced87f0fa7b (patch) | |
| tree | 358cea12d4f20d6821202f040aeb9be58eb878a7 /internal/lru/get.go | |
| parent | format/commitgraph/bloom: Add commit-graph bloom filters (diff) | |
| signature | No signature | |
internal/lru: Split
Diffstat (limited to 'internal/lru/get.go')
| -rw-r--r-- | internal/lru/get.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/lru/get.go b/internal/lru/get.go new file mode 100644 index 00000000..92196003 --- /dev/null +++ b/internal/lru/get.go @@ -0,0 +1,15 @@ +package lru + +// Get returns value for key and marks it most-recently-used. +func (cache *Cache[K, V]) Get(key K) (V, bool) { + elem, ok := cache.items[key] + if !ok { + var zero V + + return zero, false + } + + cache.lru.MoveToBack(elem) + //nolint:forcetypeassert + return elem.Value.(*entry[K, V]).value, true +} |
