lru

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.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 Cache

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

Cache is a minimal string-keyed LRU cache shared by the integration module's content-hash caches. It is not safe for concurrent use; owners guard it with their own mutex.

func New

func New[V any](capacity int) *Cache[V]

New creates a cache bounded to capacity entries.

func (*Cache[V]) Get

func (c *Cache[V]) Get(key string) (V, bool)

Get returns the cached value and marks it most recently used.

func (*Cache[V]) Put

func (c *Cache[V]) Put(key string, value V)

Put stores value under key, evicting the least recently used entry when the cache is full.

type Synced added in v0.40.0

type Synced[V any] struct {
	// contains filtered or unexported fields
}

Synced is a mutex-guarded Cache with a get-or-build fast path — the access pattern every integration content-hash cache (compiled programs, resolved schemas, code map indexes, per-system clients) shares.

func NewSynced added in v0.40.0

func NewSynced[V any](capacity int) *Synced[V]

NewSynced creates a synchronized cache bounded to capacity entries.

func (*Synced[V]) GetOrBuild added in v0.40.0

func (s *Synced[V]) GetOrBuild(key string, build func() (V, error)) (V, error)

GetOrBuild returns the value cached under key, building and caching it on first sight. Build runs under the cache lock, so concurrent misses never build the same entry twice.

Jump to

Keyboard shortcuts

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