aboutsummaryrefslogtreecommitdiff
path: root/internal/lru/peek.go
blob: 8aced931253f6e96abf2ef872422a27d7b619460 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package lru

// Peek returns value for key without changing recency.
//
//nolint:ireturn
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
}