Remove k from the cache. Returns #t if it was present, #f otherwise.
Manual eviction does not count toward the :evictions stat (which tracks
capacity- and TTL-driven evictions only).
Return the cached value for k, or default (nil) on a miss.
A hit counts toward :hits and refreshes LRU recency; a miss — including an
expired entry — counts toward :misses. nil values are cacheable, so a nil
return is ambiguous: use cache/contains? or a sentinel default to distinguish.
Return the cached value for k, or run thunk, cache its result, and return it.
A hit refreshes LRU recency and never calls thunk — a cached nil is a hit too
(stored entries are distinguished from misses internally, not by value).
A miss runs thunk exactly once and stores the result, evicting if full.
Open a persistent cache backed by the stdlib kv store (a JSON file at path).
name is the process-local kv handle; entries survive across runs in the file.
Keys must be strings. Values must round-trip through JSON: keywords become
strings, string map keys come back as keywords, NaN/Infinity floats become
nil — cache only JSON-representable data. Options: :ttl-ms (nil = no expiry),
:clock-fn (for testing; defaults to time-ms). There is no :max-size/:policy —
the kv file has no recency index and every write rewrites the whole file, so
capacity eviction belongs in an in-memory cache/new, not here. Returns a
handle usable with every cache/* function; the :hits/:misses/:evictions
counters are per-process and reset on each open.
Return a memoized version of f backed by an internal cache/new.
The cache key is the full argument list (equal?-based), so multi-arg and
variadic functions work; (m 1 2) and (m 2 1) are distinct keys. Accepts the
same options map as cache/new, plus :cache — a pre-built handle to use
instead, which lets you inspect cache/stats or evict entries from outside.
Create an in-memory cache handle.
Options: :max-size (1024) entries before eviction, :ttl-ms (nil = no expiry)
milliseconds after write before an entry expires, :policy :lru (default,
evicts the least-recently-used entry) or :fifo (evicts the oldest insertion;
re-putting a key counts as re-insertion), :clock-fn (for testing; defaults to
time-ms). Expired entries are evicted lazily on access and never count as hits.
Keys are compared with equal?, so lists, strings, and maps all work as keys.
Store v under k, evicting per the cache's policy if it is full.
Overwriting an existing key never evicts; it refreshes the entry's TTL clock,
LRU recency, and (for :fifo) its insertion order. Returns nil.