Raxol. Performance. ETS. CacheHelper
(Raxol v2.6.0)
View Source
Shared helpers for ETS-backed LRU and simple caches.
Summary
Functions
Evicts the oldest entries (by timestamp in element position 3)
when the table exceeds max_entries.
LRU lookup: returns {:ok, value} if found (updating the access timestamp),
or :miss on cache miss.
Simple cache lookup: returns the cached value or calls compute_fn
on miss, caching the result. No TTL or LRU tracking.
LRU insert: stores {key, value, now} and evicts oldest entries
when the table exceeds max_entries.
Functions
@spec enforce_limit(atom(), pos_integer()) :: :ok
Evicts the oldest entries (by timestamp in element position 3)
when the table exceeds max_entries.
LRU lookup: returns {:ok, value} if found (updating the access timestamp),
or :miss on cache miss.
Expects entries stored as {key, value, timestamp}.
Simple cache lookup: returns the cached value or calls compute_fn
on miss, caching the result. No TTL or LRU tracking.
Expects entries stored as {key, value}.
@spec put_lru(atom(), term(), term(), pos_integer()) :: :ok
LRU insert: stores {key, value, now} and evicts oldest entries
when the table exceeds max_entries.