cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LruCache

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

func NewLruCache

func NewLruCache[K comparable, V any](itemLimit uint32) *LruCache[K, V]

func (*LruCache[K, V]) Delete

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

func (*LruCache[K, V]) Get

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

func (*LruCache[K, V]) Set

func (c *LruCache[K, V]) Set(key K, value V, lifetime time.Duration)

Set adds a value to the cache with an optional lifetime. If adding this item would exceed the item limit, the least recently used item is evicted. If lifetime is greater than 0, the item is deleted after the lifetime. Otherwise, if lifetime is 0, the item is not going to be expired.

Jump to

Keyboard shortcuts

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