Versions in this module Expand all Collapse all v0 v0.0.1 Sep 29, 2026 Changes in this version + const DefaultCompactionThreshold + const DefaultEvictionRetentionRatio + const DefaultEvictionThreshold + var ErrEntryNotExist = errors.New("entry with given key does not exist") + var ErrInvalidEntry = errors.New("nil values are not supported") + var ErrInvalidEntrySize = errors.New("size of the entry is more than the cache's maxSize") + var ErrInvalidUpdateEntrySize = errors.New("size of entry to be updated is not same as existing size") + type Backend uint8 + const BackendArenaRadix + const BackendMap + const BackendRadix + func (b Backend) String() string + type BytesValue struct + func NewBytesValue(b []byte) BytesValue + func (b BytesValue) Bytes() []byte + func (b BytesValue) Size() uint64 + type Cache interface + Erase func(key string) (value ValueType) + EraseEntriesWithGivenPrefix func(prefix string) + Insert func(key string, value ValueType) ([]ValueType, error) + LookUp func(key string) (value ValueType) + LookUpWithoutChangingOrder func(key string) (value ValueType) + UpdateSize func(key string, sizeDelta uint64) error + UpdateWithoutChangingOrder func(key string, value ValueType) error + func New(maxSize uint64, opts ...Option) Cache + func NewArenaRadixCache(maxSize uint64, opts ...Option) Cache + func NewMapCache(maxSize uint64, opts ...Option) Cache + func NewRadixCache(maxSize uint64, opts ...Option) Cache + type Option func(*Options) + func WithBackend(backend Backend) Option + func WithCompactionThreshold(threshold float64) Option + func WithEvictionRetentionRatio(ratio float64) Option + func WithEvictionThreshold(threshold float64) Option + func WithInvariantChecking(enabled bool) Option + func WithMemoryBudget(bytes uint64) Option + func WithPressureFunc(fn PressureFunc) Option + type Options struct + Backend Backend + CompactionThreshold float64 + EnableInvariantChecking bool + EvictionRetentionRatio float64 + EvictionThreshold float64 + MemoryBudget uint64 + PressureFunc PressureFunc + func ApplyOptions(opts ...Option) Options + type PressureAwareCache interface + Compact func() + EvaluateMemoryPressure func() []ValueType + type PressureFunc func() float64 + func DefaultRuntimePressureFunc(memoryBudget uint64) PressureFunc + type SizedValue struct + ByteSize uint64 + Value T + func NewSizedValue[T any](val T, size uint64) SizedValue[T] + func NewValue[T any](val T, size uint64) SizedValue[T] + func (v SizedValue[T]) Size() uint64 + func (v SizedValue[T]) Unwrap() T + type StringValue string + func NewStringValue(s string) StringValue + func (s StringValue) Size() uint64 + func (s StringValue) String() string + type ValueType interface + Size func() uint64