wtinylfu

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WTinyLFUCache

type WTinyLFUCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

WTinyLFUCache is a Windowed TinyLFU cache implementation. It uses a window cache (1%) and SLRU main cache (99%) with frequency-based admission policy.

func NewWTinyLFUCache

func NewWTinyLFUCache[K comparable, V any](capacity int) *WTinyLFUCache[K, V]

NewWTinyLFUCache creates a new Windowed TinyLFU cache with the specified capacity. The cache uses a window cache (1%) and SLRU main cache (99%) with frequency-based admission.

func NewWTinyLFUCacheWithEvictionCallback

func NewWTinyLFUCacheWithEvictionCallback[K comparable, V any](capacity int, onEviction base.EvictionCallback[K, V]) *WTinyLFUCache[K, V]

NewWTinyLFUCacheWithEvictionCallback creates a new Windowed TinyLFU cache with the specified capacity and eviction callback.

func (*WTinyLFUCache[K, V]) Algorithm

func (c *WTinyLFUCache[K, V]) Algorithm() string

Algorithm returns the name of the eviction algorithm used by the cache.

func (*WTinyLFUCache[K, V]) All

func (c *WTinyLFUCache[K, V]) All() map[K]V

All returns all key-value pairs in the cache.

func (*WTinyLFUCache[K, V]) Capacity

func (c *WTinyLFUCache[K, V]) Capacity() int

Capacity returns the maximum number of items the cache can hold.

func (*WTinyLFUCache[K, V]) Delete

func (c *WTinyLFUCache[K, V]) Delete(key K) bool

Delete removes a key from the cache.

func (*WTinyLFUCache[K, V]) DeleteMany

func (c *WTinyLFUCache[K, V]) DeleteMany(keys []K) map[K]bool

DeleteMany removes multiple keys from the cache.

func (*WTinyLFUCache[K, V]) Get

func (c *WTinyLFUCache[K, V]) Get(key K) (value V, ok bool)

Get retrieves a value from the cache.

func (*WTinyLFUCache[K, V]) GetMany

func (c *WTinyLFUCache[K, V]) GetMany(keys []K) (map[K]V, []K)

GetMany retrieves multiple values from the cache.

func (*WTinyLFUCache[K, V]) Has

func (c *WTinyLFUCache[K, V]) Has(key K) bool

Has checks if a key exists in the cache.

func (*WTinyLFUCache[K, V]) HasMany

func (c *WTinyLFUCache[K, V]) HasMany(keys []K) map[K]bool

HasMany checks if multiple keys exist in the cache.

func (*WTinyLFUCache[K, V]) Keys

func (c *WTinyLFUCache[K, V]) Keys() []K

Keys returns all keys currently in the cache.

func (*WTinyLFUCache[K, V]) Len

func (c *WTinyLFUCache[K, V]) Len() int

Len returns the current number of items in the cache.

func (*WTinyLFUCache[K, V]) Peek

func (c *WTinyLFUCache[K, V]) Peek(key K) (value V, ok bool)

Peek retrieves a value from the cache without updating access order.

func (*WTinyLFUCache[K, V]) PeekMany

func (c *WTinyLFUCache[K, V]) PeekMany(keys []K) (map[K]V, []K)

PeekMany retrieves multiple values from the cache without updating access order.

func (*WTinyLFUCache[K, V]) Purge

func (c *WTinyLFUCache[K, V]) Purge()

Purge removes all keys and values from the cache.

func (*WTinyLFUCache[K, V]) Range

func (c *WTinyLFUCache[K, V]) Range(f func(K, V) bool)

Range iterates over all key-value pairs in the cache.

func (*WTinyLFUCache[K, V]) Set

func (c *WTinyLFUCache[K, V]) Set(key K, value V)

Set stores a key-value pair in the cache.

func (*WTinyLFUCache[K, V]) SetMany

func (c *WTinyLFUCache[K, V]) SetMany(items map[K]V)

SetMany stores multiple key-value pairs in the cache.

func (*WTinyLFUCache[K, V]) SizeBytes

func (c *WTinyLFUCache[K, V]) SizeBytes() int64

SizeBytes returns the total size of all cache entries in bytes.

func (*WTinyLFUCache[K, V]) Values

func (c *WTinyLFUCache[K, V]) Values() []V

Values returns all values currently in the cache.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL