Run NodesReference

cache

Package cache

import "github.com/luxfi/node/cache"

Types

Cacher

Cacher acts as a best effort key value store.

func NewSizedLRU[K comparable, V any](maxSize int, size func(K, V) int) Cacher[K, V]

Empty

Empty is a cache that doesn't store anything.

func (*Empty[K, _]) Evict(K)
func (*Empty[_, _]) Flush()
func (*Empty[K, V]) Get(K) (V, bool)
func (*Empty[_, _]) Len() int
func (*Empty[_, _]) PortionFilled() float64
func (*Empty[K, V]) Put(K, V)

LRU

LRU is a key value store with bounded size. If the size is attempted to be exceeded, then an element is removed from the cache before the insertion is done, based on evicting the least recently used value.

func NewLRU[K comparable, V any](size int) *LRU[K, V]
func (c *LRU[K, _]) Evict(key K)
func (c *LRU[_, _]) Flush()
func (c *LRU[K, V]) Get(key K) (V, bool)
func (c *LRU[_, _]) Len() int
func (c *LRU[_, _]) PortionFilled() float64
func (c *LRU[K, V]) Put(key K, value V)