Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elem ¶
type Elem[K comparable, V any] struct { Next, Prev *Elem[K, V] K K V V }
Elem is an element of a linked list.
type List ¶
type List[K comparable, V any] struct { Root *Elem[K, V] Size int }
List represents a doubly linked list.
type Lru ¶
type Lru[K comparable, V any] struct { // Size is the maximum number of cache entries before // an item is evicted. Zero means no limit. Size int List *List[K, V] C map[K]*Elem[K, V] M *sync.Mutex }
Lru cache. It is safe for concurrent access.
func New ¶
func New[K comparable, V any](size int) *Lru[K, V]
New returns a new LRU cache. If size is zero, the cache has no limit.
func (*Lru[K, V]) Get ¶
func (l *Lru[K, V]) Get(k K) (v V)
Get looks up a key's value from the cache.
Click to show internal directories.
Click to hide internal directories.