package lru
import "golang.org/x/pkgsite/internal/lru"
Package lru provides an LRU cache.
Index ¶
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 ¶
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.
Source Files ¶
lru.go
- Version
- v0.0.0-20250218150137-224a1368cf02 (latest)
- Published
- Feb 18, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 2 months ago –
Tools for package owners.