A caching library for Clojure implementing various cache strategies
https://github.com/clojure/core.cache
The core.cache library API has always assumed that you store the (immutable) caches in a Clojure reference type (usually an atom) so it has often been confusing to newcomers and it comes with a far bit of boilerplate since all that atom-wrapping code gets written by everyone and there are some edge cases to watch out for (such as potential cache stampede when using `through` or `through-cache` because of potential retries).
The 0.8.0 release adds a new namespace, clojure.core.cache.wrapped, that is “identical” to the main API but operates on atoms (containing caches) instead of bare caches. The factory functions return atoms, all the other functions accept atoms (but return the same thing as the main API – often the updated immutable cache itself). The 0.8.1 release fixes a bug in 0.8.0’s wrapped TTL cache.
There’s also a new `lookup-or-miss` function that’s like `through-cache` in the old API but avoids cache stampede by only evaluating `wrap-fn` and `value-fn` at most once, no matter how many retries there are.
This is a completely additive release (despite the 0.7.2 -> 0.8.x version bump, which reflects the new API namespace addition) and I hope it will make core.cache easier to use for the “mainstream” cases in the wild.
See https://cljdoc.org/d/org.clojure/core.cache/0.8.0/api/clojure.core.cache.wrapped#lookup-or-miss for the new function.
Reminder: Contrib projects are governed by the Clojure CA process and use JIRA/patches:
https://clojure.atlassian.net/projects/CCACHE/issues/?filter=allopenissues
If you don’t have a JIRA account, you can raise issues (and ask questions) about core.cache here:
https://ask.clojure.org/index.php/questions/contrib-libs/core-cache
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood