Documentation
¶
Overview ¶
Package cache provides a generic, thread-safe LRU cache with O(log n) eviction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRU ¶
type LRU[K comparable, V any] struct { // contains filtered or unexported fields }
LRU is a generic least-recently-used cache with O(log n) eviction via a min-heap.
func New ¶
func New[K comparable, V any](maxSize int) *LRU[K, V]
New creates an LRU cache with the given maximum size.
func (*LRU[K, V]) DeleteFunc ¶
DeleteFunc removes all entries for which fn returns true.
func (*LRU[K, V]) Get ¶
Get returns the value for the key and true, or the zero value and false. Accessing a key refreshes its position (most recently used).
Click to show internal directories.
Click to hide internal directories.