Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastStructCache ¶
type FastStructCache[KT, VT any] struct { Cache *fastcache.Cache // contains filtered or unexported fields }
FastStructCache is an in-memory key-value store intended to be able to store larger structs (although any data type should work). It wraps fastcache from VictoriaMetrics with the binary codec from kelindar, and optional snappy-like compression (S2 from klauspost).
func New ¶
func New[KT, VT any](mb int, compress bool) FastStructCache[KT, VT]
New returns new cache with the given maxBytes capacity in bytes (min 32MB), with optional light compression.
func (FastStructCache[KT, VT]) Del ¶
func (c FastStructCache[KT, VT]) Del(k KT)
Del deletes value for the given k from the cache.
func (FastStructCache[KT, VT]) Get ¶
func (c FastStructCache[KT, VT]) Get(k KT) *VT
Get returns pointer to a value stored for given key k, or nil if it didn't exist in the cache
func (FastStructCache[KT, VT]) Has ¶
func (c FastStructCache[KT, VT]) Has(k KT) bool
Has returns true if entry for the given key k exists in the cache.
func (FastStructCache[KT, VT]) Reset ¶
func (c FastStructCache[KT, VT]) Reset()
Reset removes all the items from the cache.
func (FastStructCache[KT, VT]) Set ¶
func (c FastStructCache[KT, VT]) Set(k KT, v VT)
Set stores (k, v) in the cache.