aboutsummaryrefslogtreecommitdiff
path: root/internal/lru/peek.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-06 04:43:03 +0800
committerGravatar Runxi Yu2026-03-06 04:43:03 +0800
commitfec8b64975f952e2fa5fa8478b09dced87f0fa7b (patch)
tree358cea12d4f20d6821202f040aeb9be58eb878a7 /internal/lru/peek.go
parentformat/commitgraph/bloom: Add commit-graph bloom filters (diff)
signatureNo signature
internal/lru: Split
Diffstat (limited to 'internal/lru/peek.go')
-rw-r--r--internal/lru/peek.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/lru/peek.go b/internal/lru/peek.go
new file mode 100644
index 00000000..3a308394
--- /dev/null
+++ b/internal/lru/peek.go
@@ -0,0 +1,13 @@
+package lru
+
+// Peek returns value for key without changing recency.
+func (cache *Cache[K, V]) Peek(key K) (V, bool) {
+ elem, ok := cache.items[key]
+ if !ok {
+ var zero V
+
+ return zero, false
+ }
+ //nolint:forcetypeassert
+ return elem.Value.(*entry[K, V]).value, true
+}