lru

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache[K comparable, V any](capacity int) cache.Cacher[K, V]

NewCache creates a new LRU cache with the given capacity

Types

type Cache

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

Cache implements an LRU cache

func (*Cache[K, V]) Evict

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

Evict removes a key from the cache

func (*Cache[K, V]) Flush

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

Flush clears the cache

func (*Cache[K, V]) Get

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

Get retrieves a value from the cache

func (*Cache[K, V]) Len

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

Len returns the number of items in the cache

func (*Cache[K, V]) Put

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

Put adds a key-value pair to the cache

Jump to

Keyboard shortcuts

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