lru

package
v0.0.0-...-9e89dfb Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package lru provides an LRU cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is an LRU cache.

func New

func New[K comparable, V any](size int) *Cache[K, V]

New returns a new Cache. Size must be positive or it will panic.

func (*Cache[K, V]) Get

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

Get gets the entry for k in the Cache.

func (*Cache[K, V]) Put

func (c *Cache[K, V]) Put(k K, v V)

Put puts in an entry for k, v in Cache, evicting the least recently used entry if necessary.

Jump to

Keyboard shortcuts

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