Documentation ¶
Overview ¶
nolint:forcetypeassert
Index ¶
- type LFU
- func (c *LFU[K, V]) Add(key K, value V)
- func (c *LFU[K, V]) Close() error
- func (c *LFU[K, V]) Evict()
- func (c *LFU[K, V]) Get(key K) (value V, ok bool)
- func (c *LFU[K, V]) Peek(key K) (value V, ok bool)
- func (c *LFU[K, V]) Purge()
- func (c *LFU[K, V]) Remove(key K)
- func (c *LFU[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 LFU ¶
type LFU[K comparable, V any] struct { // contains filtered or unexported fields }
LFU is a thread-safe fixed size LFU cache.
func New ¶
func New[K comparable, V any](reg prometheus.Registerer, opts ...Option[K, V]) *LFU[K, V]
func (*LFU[K, V]) Evict ¶
func (c *LFU[K, V]) Evict()
Evict one element from the cache depending on the eviction policy.
func (*LFU[K, V]) Remove ¶
func (c *LFU[K, V]) Remove(key K)
Remove removes the provided key from the cache.
func (*LFU[K, V]) RemoveMatching ¶
RemoveMatching removes items from the cache that match the predicate.
type Option ¶
type Option[K comparable, V any] func(lfu *LFU[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.