core.cache TTL cache expiration visibility between lookup and has?
0 reputation · 08 Dec 2024, 15:06 UTC
The documented TTL cache type in clojure.core.cache associates each entry with an expiration threshold. The unresolved behavior is whether expiration is implemented as eager eviction or as a lazy filter applied on lookup, and how that choice is exposed by the cache API.
The decision matters for consistency across access paths. A read-through helper typically recomputes only on a cache miss, so any difference between lookup semantics and presence checks can lead to divergent freshness guarantees. Behavior is version-sensitive across core.cache releases and may differ from memoization wrappers built on top of it.
For a pinned core.cache version using ttl-cache-factory, does lookup return nil for an expired entry while has? still reports the key as present? Does a through-cache style read-through treat an expired entry as a hit or a miss? Which API surface should be used as the authoritative freshness check?