aboutsummaryrefslogtreecommitdiff
path: root/internal/lru/peek.go
blob: 3a3083949f27590736febbd52f0d9a8709ecddbf (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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
}