Documentation ¶
Index ¶
- type LRU
- func (c *LRU[K, V]) Add(key K, value V)
- func (c *LRU[K, V]) Close() error
- func (c *LRU[K, V]) Get(key K) (value V, ok bool)
- func (c *LRU[K, V]) Peek(key K) (value V, ok bool)
- func (c *LRU[K, V]) Purge()
- func (c *LRU[K, V]) Remove(key K)
- func (c *LRU[K, V]) RemoveMatching(predicate func(key K, value V) bool)
- type Option
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 }
func New ¶
func New[K comparable, V any](reg prometheus.Registerer, opts ...Option[K, V]) *LRU[K, V]
New returns a new cache with the provided maximum items count.
func (*LRU[K, V]) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*LRU[K, V]) Remove ¶
func (c *LRU[K, V]) Remove(key K)
Remove removes the provided key from the cache.
func (*LRU[K, V]) RemoveMatching ¶
removeMatching removes items from the cache that match the predicate.
type Option ¶
type Option[K comparable, V any] func(lru *LRU[K, V])
func WithMaxSize ¶
func WithMaxSize[K comparable, V any](maxSize int) Option[K, V]
func WithOnAdded ¶
func WithOnAdded[K comparable, V any](onAdded func(key K, value V)) Option[K, V]
func WithOnEvict ¶
func WithOnEvict[K comparable, V any](onEvict func(key K, value V)) Option[K, V]
Click to show internal directories.
Click to hide internal directories.