(cache-stats->map cs)
Convert a CacheStats object readonly attributes to a Clojure map.
See: https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/2.8.0/com/github/benmanes/caffeine/cache/stats/CacheStats.html for actual metrics docs.
Convert a CacheStats object readonly attributes to a Clojure map. See: https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/2.8.0/com/github/benmanes/caffeine/cache/stats/CacheStats.html for actual metrics docs.
(make-builder settings)
A builder for the various types of Caffeine's caches (AsyncCache,
AsyncLoadingCache, Cache, LoadingCache). The corresponding create
functions,
accept and pass here this config to create the required cache.
settings
is a map with the keys (all optional):
:recordStats
boolean
:statsCounterSupplier
a com.github.benmanes.caffeine.cache.stats.StatsCounter
,
mutually exclusive with :recordStats
:maximumSize
long
Specifies the maximum number of entries the cache may contain.:expireAfter
com.github.benmanes.caffeine.cache.Expiry
:expireAfterAccess
long
, references :timeUnit. Specifies that each entry
should be automatically removed from the cache once a fixed duration has
elapsed after the entry's creation, the most recent replacement of its value,
or its last read.:expireAfterWrite
long
, references :timeUnit. Specifies that active entries
are eligible for automatic refresh once a fixed duration has elapsed after
the entry's creation, or the most recent replacement of its value.:executor
java.util.concurrent.Executor
Specifies the executor to use when
running asynchronous tasks.:weakKeys
boolean
. Specifies that each key (not value) stored in the cache
should be wrapped in a WeakReference (by default, strong references are used).:initialCapacity
'long'. Sets the minimum total size for the internal data structures.:softValues
Boolean
Specifies that each value (not key) stored in the cache
should be wrapped in a SoftReference (by default, strong references are used).
Softly-referenced objects will be garbage-collected in a globally
least-recently-used manner, in response to memory demand.:ticker
com.github.benmanes.caffeine.cache.Ticker
Specifies a
nanosecond-precision time source for use in determining when entries should
be expired or refreshed. By default, System.nanoTime() is used.:weigher
com.github.benmanes.caffeine.cache.Weigher
Specifies the weigher
to use in determining the weight of entries.:evictionListener
com.github.benmanes.caffeine.cache.RemovalListener
Specifies a listener instance that caches should notify each time an entry
is removed for any reason. Each cache created by this builder will invoke
this listener as part of the routine maintenance described in the class
documentation above.:timeUnit
[:ms :us :s :m :h :d]
default is :s
A builder for the various types of Caffeine's caches (AsyncCache, AsyncLoadingCache, Cache, LoadingCache). The corresponding `create` functions, accept and pass here this config to create the required cache. `settings` is a map with the keys (all optional): * `:recordStats` `boolean` * `:statsCounterSupplier` a `com.github.benmanes.caffeine.cache.stats.StatsCounter`, mutually exclusive with `:recordStats` * `:maximumSize` `long` Specifies the maximum number of entries the cache may contain. * `:expireAfter` `com.github.benmanes.caffeine.cache.Expiry` * `:expireAfterAccess` `long`, references :timeUnit. Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read. * `:expireAfterWrite` `long`, references :timeUnit. Specifies that active entries are eligible for automatic refresh once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value. * `:executor` `java.util.concurrent.Executor` Specifies the executor to use when running asynchronous tasks. * `:weakKeys` `boolean`. Specifies that each key (not value) stored in the cache should be wrapped in a WeakReference (by default, strong references are used). * `:initialCapacity` 'long'. Sets the minimum total size for the internal data structures. * `:softValues` `Boolean` Specifies that each value (not key) stored in the cache should be wrapped in a SoftReference (by default, strong references are used). Softly-referenced objects will be garbage-collected in a globally least-recently-used manner, in response to memory demand. * `:ticker` `com.github.benmanes.caffeine.cache.Ticker` Specifies a nanosecond-precision time source for use in determining when entries should be expired or refreshed. By default, System.nanoTime() is used. * `:weigher` `com.github.benmanes.caffeine.cache.Weigher` Specifies the weigher to use in determining the weight of entries. * `:evictionListener` `com.github.benmanes.caffeine.cache.RemovalListener` Specifies a listener instance that caches should notify each time an entry is removed for any reason. Each cache created by this builder will invoke this listener as part of the routine maintenance described in the class documentation above. * `:timeUnit` ``[:ms :us :s :m :h :d]`` default is `:s`
(reify-async-cache-loader loading-fn)
(reify-async-cache-loader loading-fn reloading-fn)
A helper for implementing an AsyncCacheLoader
.
loading-fn
- (fn [this k executor])
. Asynchronously computes or retrieves
the value corresponding to key.reloading-fn
(optional) (fn [this k old-val executor])
Asynchronously
computes or retrieves a replacement value corresponding to an already-cached
key. If the replacement value is not found then the mapping will be removed
if nil is computed. This method is called when an existing cache entry is
refreshed by Caffeine.refreshAfterWrite(java.time.Duration),
or through a call to LoadingCache.refresh(K).A helper for implementing an `AsyncCacheLoader`. * `loading-fn` - `(fn [this k executor])`. Asynchronously computes or retrieves the value corresponding to key. * `reloading-fn` (optional) ``(fn [this k old-val executor])`` Asynchronously computes or retrieves a replacement value corresponding to an already-cached key. If the replacement value is not found then the mapping will be removed if nil is computed. This method is called when an existing cache entry is refreshed by Caffeine.refreshAfterWrite(java.time.Duration), or through a call to LoadingCache.refresh(K).
(reify-cache-loader loading-fn)
(reify-cache-loader loading-fn reloading-fn)
A helper for implementing CacheLoader
.
loading-fn
- (fn [this k])
. Computes or retrieves the value corresponding
to key.relaoding-fn
- (fn [this k old-val])
. Computes or retrieves a replacement
value corresponding to an already-cached key.A helper for implementing `CacheLoader`. * `loading-fn` - `(fn [this k])`. Computes or retrieves the value corresponding to key. * `relaoding-fn` - `(fn [this k old-val])`. Computes or retrieves a replacement value corresponding to an already-cached key.
(reify-removal-listener removal-handler)
A helper for implementing RemovalListener
removal-handler
- (fn [k v removal-cause])
. React upon removal
of k. cause
is a RemovalCause
enum: {COLLECTED|EXPIRED|EXPLICIT|REPLACED|SIZE}A helper for implementing `RemovalListener` * `removal-handler` - `(fn [k v removal-cause])`. React upon removal of k. `cause` is a `RemovalCause` enum: {COLLECTED|EXPIRED|EXPLICIT|REPLACED|SIZE}
(reify-weigher weigh-fn)
A helper for implementing Weigher
.
weigh-fn
- (fn [this k v])
. Returns the weight of a cache entry (int).
There is no unit for entry weights; rather they are simply relative to each other.A helper for implementing `Weigher`. * `weigh-fn` - `(fn [this k v])`. Returns the weight of a cache entry (int). There is no unit for entry weights; rather they are simply relative to each other.
(stats c)
Returns a current snapshot of this cache's cumulative statistics.
Returns a current snapshot of this cache's cumulative statistics.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close