(as-map cache)
Return a caffeine cache as a map. Some Useful methods are .putIfAbsent and computeIfAbsent.
Return a caffeine cache as a map. Some Useful methods are .putIfAbsent and computeIfAbsent.
(cache {:keys [write-ttl-ms access-ttl-ms soft-values? weak-values? max-size
record-stats? eviction-fn weight-limited load-fn]})
Create a caffeine cache.
Options:
:write-ttl-ms
- Time that values should remain in the cache after write in milliseconds.:access-ttl-ms
- Time that values should remain in the cache after access in milliseconds.:soft-values?
- When true, the cache will store SoftReferences to the data.:weak-values?
- When true, the cache will store WeakReferences to the data.:max-size
- When set, the cache will behave like an LRU cache.:record-stats?
- When true, the LoadingCache will record access statistics. You can
get those via the undocumented function memo-stats.:eviction-fn
- Function that receives 3 arguments, [args v cause], when a value is
evicted. Causes the keywords :collected :expired :explicit :replaced and :size
. See
caffeine documentation for cause definitions.:weight-limited
- tuple of [weight-fn max-weight]
. weight-fn takes 2 args - k, v.:load-fn
- Pass in a function that will automatically compute the answer.Create a caffeine cache. Options: * `:write-ttl-ms` - Time that values should remain in the cache after write in milliseconds. * `:access-ttl-ms` - Time that values should remain in the cache after access in milliseconds. * `:soft-values?` - When true, the cache will store [SoftReferences](https://docs.oracle.com/javase/7/docs/api/java/lang/ref/SoftReference.html) to the data. * `:weak-values?` - When true, the cache will store [WeakReferences](https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html) to the data. * `:max-size` - When set, the cache will behave like an LRU cache. * `:record-stats?` - When true, the LoadingCache will record access statistics. You can get those via the undocumented function memo-stats. * `:eviction-fn` - Function that receives 3 arguments, [args v cause], when a value is evicted. Causes the keywords `:collected :expired :explicit :replaced and :size`. See [caffeine documentation](https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/2.9.3/com/github/benmanes/caffeine/cache/RemovalCause.html) for cause definitions. * `:weight-limited` - tuple of `[weight-fn max-weight]`. weight-fn takes 2 args - k, v. * `:load-fn` - Pass in a function that will automatically compute the answer.
(get-if-present c k)
(get-or-load! c k load-fn)
(invalidate! c k)
Invalidate an entry. Returns the cache.
Invalidate an entry. Returns the cache.
(invalidate-all! c)
(invalidate-all! c ks)
Invalidate all entries or all entries with given keys. Returns cache.
Invalidate all entries or all entries with given keys. Returns cache.
(keyword-stats cache)
Return a persistent map with keyword keys and caffeine stat values.
Returns:
{:hit-count (.hitCount stats) :hit-rate (.hitRate stats) :miss-count (.missCount stats) :miss-rate (.missRate stats) :load-success-count (.loadSuccessCount stats) :average-load-penalty-nanos (.averageLoadPenalty stats) :total-load-time-nanos (.totalLoadTime stats) :eviction-count (.evictionCount stats)}
Return a persistent map with keyword keys and caffeine stat values. Returns: `{:hit-count (.hitCount stats) :hit-rate (.hitRate stats) :miss-count (.missCount stats) :miss-rate (.missRate stats) :load-success-count (.loadSuccessCount stats) :average-load-penalty-nanos (.averageLoadPenalty stats) :total-load-time-nanos (.totalLoadTime stats) :eviction-count (.evictionCount stats)}`
(stats cache)
Return the caffeine cache stats.
Return the caffeine cache stats.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close