lru

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package lru provides a small thread-safe LRU cache with a per-entry TTL. The engine uses it to reuse a parsed *workflow.Graph across the many steps of one flow instead of re-unmarshalling the frozen graph JSON every step.

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 a small thread-safe LRU with a per-entry TTL.

func New

func New[K comparable, V any](maxEntries int, ttl time.Duration) *Cache[K, V]

New creates a cache bounded to maxEntries with the given per-entry TTL. A non-positive maxEntries disables eviction by count; a non-positive ttl disables expiry.

func (*Cache[K, V]) Load

func (c *Cache[K, V]) Load(key K) (V, bool)

Load returns the value for key if present and not expired, marking it most-recently-used.

func (*Cache[K, V]) Store

func (c *Cache[K, V]) Store(key K, value V)

Store inserts or updates key, evicting the least-recently-used entry when over capacity.

Jump to

Keyboard shortcuts

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