cache

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRU

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

LRU is a thread-safe least recently used cache with a fixed size.

func NewLRU

func NewLRU[K comparable, V any](size int) *LRU[K, V]

NewLRU creates a new LRU cache with the given size

func (*LRU[K, V]) Evict

func (c *LRU[K, V]) Evict(key K)

Evict removes a key from the cache

func (*LRU[K, V]) Flush

func (c *LRU[K, V]) Flush()

Flush removes all entries from the cache

func (*LRU[K, V]) Get

func (c *LRU[K, V]) Get(key K) (V, bool)

Get retrieves a value from the cache

func (*LRU[K, V]) Len

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

Len returns the number of items in the cache

func (*LRU[K, V]) Put

func (c *LRU[K, V]) Put(key K, value V)

Put adds or updates a key-value pair in the cache

Jump to

Keyboard shortcuts

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