lfu

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEvictionSize is the number of element to evict when the cache is full.
	DefaultEvictionSize = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LFUCache

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

Cache is an LFU cache. It is not safe for concurrent access.

func NewLFUCache

func NewLFUCache[K comparable, V any](capacity int) *LFUCache[K, V]

func NewLFUCacheWithEvictionCallback added in v0.2.0

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

func NewLFUCacheWithEvictionSize

func NewLFUCacheWithEvictionSize[K comparable, V any](capacity int, evictionSize int) *LFUCache[K, V]

func NewLFUCacheWithEvictionSizeAndCallback added in v0.2.0

func NewLFUCacheWithEvictionSizeAndCallback[K comparable, V any](capacity int, evictionSize int, onEviction base.EvictionCallback[K, V]) *LFUCache[K, V]

func (*LFUCache[K, V]) Algorithm

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Capacity

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Delete

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

implements base.InMemoryCache

func (*LFUCache[K, V]) DeleteLeastFrequent

func (c *LFUCache[K, V]) DeleteLeastFrequent() (k K, v V, ok bool)

func (*LFUCache[K, V]) DeleteMany

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Get

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

implements base.InMemoryCache

func (*LFUCache[K, V]) GetMany

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Has

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

implements base.InMemoryCache

func (*LFUCache[K, V]) HasMany

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Keys

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Len

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Peek

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

implements base.InMemoryCache

func (*LFUCache[K, V]) PeekMany

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Purge

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Range

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Set

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

implements base.InMemoryCache

func (*LFUCache[K, V]) SetMany

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

implements base.InMemoryCache

func (*LFUCache[K, V]) Values

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

implements base.InMemoryCache

Jump to

Keyboard shortcuts

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