Documentation
¶
Index ¶
- Constants
- type LFUCache
- func NewLFUCache[K comparable, V any](capacity int) *LFUCache[K, V]
- func NewLFUCacheWithEvictionCallback[K comparable, V any](capacity int, onEviction base.EvictionCallback[K, V]) *LFUCache[K, V]
- func NewLFUCacheWithEvictionSize[K comparable, V any](capacity int, evictionSize int) *LFUCache[K, V]
- func NewLFUCacheWithEvictionSizeAndCallback[K comparable, V any](capacity int, evictionSize int, onEviction base.EvictionCallback[K, V]) *LFUCache[K, V]
- func (c *LFUCache[K, V]) Algorithm() string
- func (c *LFUCache[K, V]) Capacity() int
- func (c *LFUCache[K, V]) Delete(key K) bool
- func (c *LFUCache[K, V]) DeleteLeastFrequent() (k K, v V, ok bool)
- func (c *LFUCache[K, V]) DeleteMany(keys []K) map[K]bool
- func (c *LFUCache[K, V]) Get(key K) (value V, ok bool)
- func (c *LFUCache[K, V]) GetMany(keys []K) (map[K]V, []K)
- func (c *LFUCache[K, V]) Has(key K) bool
- func (c *LFUCache[K, V]) HasMany(keys []K) map[K]bool
- func (c *LFUCache[K, V]) Keys() []K
- func (c *LFUCache[K, V]) Len() int
- func (c *LFUCache[K, V]) Peek(key K) (value V, ok bool)
- func (c *LFUCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
- func (c *LFUCache[K, V]) Purge()
- func (c *LFUCache[K, V]) Range(f func(K, V) bool)
- func (c *LFUCache[K, V]) Set(key K, value V)
- func (c *LFUCache[K, V]) SetMany(items map[K]V)
- func (c *LFUCache[K, V]) Values() []V
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]) DeleteLeastFrequent ¶
func (*LFUCache[K, V]) DeleteMany ¶
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]) PeekMany ¶
func (c *LFUCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
implements base.InMemoryCache
func (*LFUCache[K, V]) Set ¶
func (c *LFUCache[K, V]) Set(key K, value V)
implements base.InMemoryCache
Click to show internal directories.
Click to hide internal directories.