package lfu

import "git.sr.ht/~xn/cache/v2/lfu"

Index

Types

type LFU

type LFU[V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LFU - Least Frequently Used cache

func New

func New[V any](size int) *LFU[V]

New LFU cache

func (*LFU[V]) Get

func (c *LFU[V]) Get(key string) V

Get an item from cache

func (*LFU[V]) Has

func (c *LFU[V]) Has(key string) bool

Has check if an item exists in cache, without useness update

func (*LFU[V]) Purge

func (c *LFU[V]) Purge()

Purge cache

func (*LFU[V]) Remove

func (c *LFU[V]) Remove(key string)

Remove an item from cache

func (*LFU[V]) Set

func (c *LFU[V]) Set(key string, value V)

Set an item to cache

Source Files

lfu.go

Version
v2.1.0 (latest)
Published
Aug 29, 2022
Platform
linux/amd64
Imports
3 packages
Last checked
1 day ago

Tools for package owners.