cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 1 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 {
	// contains filtered or unexported fields
}

LRU is a generic, thread-safe least-recently-used cache.

func NewLRU

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

func (*LRU[K, V]) Clear

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

Clear removes all items.

func (*LRU[K, V]) Delete

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

Delete removes a key from the cache.

func (*LRU[K, V]) Get

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

Get retrieves a value and moves it to the front (most recent).

func (*LRU[K, V]) Len

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

Len returns the current number of items.

func (*LRU[K, V]) Put

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

Put inserts or updates a key-value pair. Evicts LRU if at capacity.

Jump to

Keyboard shortcuts

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