Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache is a generic fixed-size LRU cache wrapping hashicorp/golang-lru/v2.
func NewCache ¶
func NewCache[K comparable, V any](size int) (*Cache[K, V], error)
NewCache creates an LRU Cache with the given maximum size. A non-positive size returns an error from the underlying implementation.
func (*Cache[K, V]) Add ¶
Add inserts or updates key with value, evicting the least-recently-used entry if the cache is full. It returns true if an eviction occurred.
func (*Cache[K, V]) Get ¶
Get returns the value for key and reports whether it was present. Accessing a key marks it as most-recently-used.
Click to show internal directories.
Click to hide internal directories.