Documentation
¶
Index ¶
- func NewLRUCache[K comparable, V any](size, buffer int, onEvict func(map[K]V)) *evictionCache[K, V]
- func NewLRUEviction[K comparable](size, buffer int, evict func([]K)) *lruEviction[K]
- func NewMapCache[K comparable, V any]() *mapCache[K, V]
- func NewTimeoutCache[K comparable, V any](evictionTimeout time.Duration, onEvict func(map[K]V)) *evictionCache[K, V]
- func NewTimeoutEviction[K comparable](timeout time.Duration, evict func([]K)) *timeoutEviction[K]
- type EvictionPolicy
- type Map
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLRUCache ¶
func NewLRUCache[K comparable, V any](size, buffer int, onEvict func(map[K]V)) *evictionCache[K, V]
NewLRUCache creates a cache with limited size with LRU eviction policy. It is guaranteed that at least size elements can be kept in the cache. The cache is cleaned up when the cache is full, i.e. it contains size + buffer elements
func NewLRUEviction ¶
func NewLRUEviction[K comparable](size, buffer int, evict func([]K)) *lruEviction[K]
func NewMapCache ¶
func NewMapCache[K comparable, V any]() *mapCache[K, V]
NewMapCache creates a dummy implementation of the Cache interface. It is backed by a map with unlimited capacity.
func NewTimeoutCache ¶
func NewTimeoutCache[K comparable, V any](evictionTimeout time.Duration, onEvict func(map[K]V)) *evictionCache[K, V]
NewTimeoutCache creates a cache that keeps elements for evictionTimeout time. An element might return even if it is marked stale.
func NewTimeoutEviction ¶
func NewTimeoutEviction[K comparable](timeout time.Duration, evict func([]K)) *timeoutEviction[K]
Types ¶
type EvictionPolicy ¶
type EvictionPolicy[K comparable] interface { // Push adds a key and must be invoked under write-lock Push(K) }
Click to show internal directories.
Click to hide internal directories.