lrucache

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLRUCapacity = 20

DefaultLRUCapacity is the default capacity of the LRU cache.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

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

Entry represents an item in the cache.

type LRUCache

type LRUCache[K comparable, V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LRUCache represents the LRU cache.

func NewLRUCache

func NewLRUCache[K comparable, V any](capacity uint) *LRUCache[K, V]

NewLRUCache creates a new LRU cache with the specified capacity.

func (*LRUCache[K, V]) Get

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

Get retrieves the value associated with the given key from the cache.

func (*LRUCache[K, V]) Put

func (c *LRUCache[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