erllama_cache (erllama v0.1.0)
View SourcePublic façade for the cache subsystem.
Tier servers, the meta server, the writer pool, and the policy
module are internal. The runtime cache plumbing (lookup_exact/1,
checkout/2, checkin/1, save_async/N, lookup_exact_or_wait/2)
lives in erllama_cache_meta_srv and erllama_cache_writer; this
module exposes only the operator-friendly subset.
Summary
Functions
Evict oldest available rows until at least TargetBytes have been
freed. Returns {evicted, NumRows, BytesFreed}.
Like evict_bytes/1, but only considers rows whose tier is in
Tiers. Pass all to match every tier, or a subset of
[ram, ram_file, disk]. The system-pressure scheduler uses this to
evict only RAM-resident slabs while leaving the disk tier alone.
Synchronous full eviction pass. Walks the LRU and drops every available row with refcount=0. Returns the number evicted.
Snapshot of operational counters as a map of slot name to non-negative integer. Suitable for forwarding to a metrics exporter (Prometheus, statsd, OpenTelemetry).
Find the longest cached prefix of Tokens for the given key
namespace. Stride and floor default to the policy's
boundary_align_tokens and min_tokens. Operator-friendly entry
point for stateless callers (HTTP front-end, agent loops) that
resend the full conversation each turn.
Like lookup_longest_prefix/2 with explicit stride and floor.
Reset all counters to 0. Mostly for tests; production callers should treat counters as monotonic-since-boot.
Types
Functions
-spec evict_bytes(non_neg_integer()) -> {evicted, non_neg_integer(), non_neg_integer()}.
Evict oldest available rows until at least TargetBytes have been
freed. Returns {evicted, NumRows, BytesFreed}.
-spec evict_bytes(non_neg_integer(), all | [tier()]) -> {evicted, non_neg_integer(), non_neg_integer()}.
Like evict_bytes/1, but only considers rows whose tier is in
Tiers. Pass all to match every tier, or a subset of
[ram, ram_file, disk]. The system-pressure scheduler uses this to
evict only RAM-resident slabs while leaving the disk tier alone.
-spec gc() -> {evicted, non_neg_integer()}.
Synchronous full eviction pass. Walks the LRU and drops every available row with refcount=0. Returns the number evicted.
-spec get_counters() -> #{atom() => non_neg_integer()}.
Snapshot of operational counters as a map of slot name to non-negative integer. Suitable for forwarding to a metrics exporter (Prometheus, statsd, OpenTelemetry).
-spec lookup_longest_prefix(map(), [non_neg_integer()]) -> {ok, pos_integer(), tuple()} | miss.
Find the longest cached prefix of Tokens for the given key
namespace. Stride and floor default to the policy's
boundary_align_tokens and min_tokens. Operator-friendly entry
point for stateless callers (HTTP front-end, agent loops) that
resend the full conversation each turn.
-spec lookup_longest_prefix(map(), [non_neg_integer()], pos_integer(), pos_integer()) -> {ok, pos_integer(), tuple()} | miss.
Like lookup_longest_prefix/2 with explicit stride and floor.
-spec reset_counters() -> ok.
Reset all counters to 0. Mostly for tests; production callers should treat counters as monotonic-since-boot.