Liking cljdoc? Tell your friends :D

fmnoise.coldbrew


build-cacheclj

(build-cache options & [cache-fn])

Builds Caffeine Loading Cache with given options and optional cache function. Supported options are: :expire - expiration time after write (in seconds) :expire-after-access - expiration time after access (in seconds) :initial-capacity - initial capacity of internal data structure :scheduler - Routine cache maintenance scheduler :executor - Executor for :removal-listener, periodic maintenance or refreshes :refresh - refresh time (in seconds) :when - function for checking if value should be cached :max-size - number, sets maximum cache size :weak-keys - boolean, switch cache to using weak references for keys :weak-values - boolean, switch cache to using weak references for values (can't be set together with :soft-values) :soft-values - boolean, switch cache to using soft references for values (can't be set together with :weak-values) :eviction-listener - function of three parameters (key, value, cause) that is called synchronously when a cache entry is evicted (due to policy) :removal-listener - function of three parameters (key, value, cause) that is called asynchronously (using :executor, if given) when a cache entry is removed (invalidated or evicted)

Builds Caffeine Loading Cache with given options and optional cache function. Supported options are:
`:expire` - expiration time after write (in seconds)
`:expire-after-access` - expiration time after access (in seconds)
`:initial-capacity` - initial capacity of internal data structure
`:scheduler` - Routine cache maintenance scheduler
`:executor` - Executor for `:removal-listener`, periodic maintenance or refreshes
`:refresh` - refresh time (in seconds)
`:when` - function for checking if value should be cached
`:max-size` - number, sets maximum cache size
`:weak-keys` - boolean, switch cache to using weak references for keys
`:weak-values` - boolean, switch cache to using weak references for values (can't be set together with `:soft-values`)
`:soft-values` - boolean, switch cache to using soft references for values (can't be set together with `:weak-values`)
`:eviction-listener` - function of three parameters (key, value, cause) that is called synchronously when a cache entry is evicted (due to policy)
`:removal-listener` - function of three parameters (key, value, cause) that is called asynchronously (using `:executor`, if given) when a cache entry is removed (invalidated or evicted)
sourceraw docstring

cachedclj

(cached f)

Accepts a function and creates cached version of it which uses Caffeine Loading Cache. Cache options can be provided as meta to function. See build-cache documentation for the list of supported-options. Examples: (cached ^{:expire 86400 :refresh 36000} (fn [db id] (query db id)))

;; calculate todays order capacity until it reaches zero (cached ^{:when zero?} (fn [db worker-id] (order-capacity db worker-id)))

Accepts a function and creates cached version of it which uses Caffeine Loading Cache.
Cache options can be provided as meta to function. See `build-cache` documentation for the list of supported-options.
Examples:
(cached ^{:expire 86400 :refresh 36000}
 (fn [db id] (query db id)))

;; calculate todays order capacity until it reaches zero
(cached ^{:when zero?}
 (fn [db worker-id] (order-capacity db worker-id)))
sourceraw docstring

cond-lookupclj

(cond-lookup cache key condition-fn computation-fn & [args])

Performs cache lookup and conditional value computation if value is missing

Performs cache lookup and conditional value computation if value is missing
sourceraw docstring

defcachedcljmacro

(defcached name & fdecl)

Creates a function which uses Caffeine Loading Cache under the hood. Function declaration is similar to defn:

  • name (symbol) with optional meta
  • docstring (optional)
  • args (vector)
  • pre/post conditions map (optional)
  • caching key (vector) with optional meta containing cache options (see cached for more details)
  • body

Example: (defcached customer-lifetime-value [db date {:customer/keys [id]}] ^{:expire 86400 :refresh 36000} [db date id] (query-customer-ltv db date id))

Creates a function which uses Caffeine Loading Cache under the hood.
Function declaration is similar to defn:
- name (symbol) with optional meta
- docstring (optional)
- args (vector)
- pre/post conditions map (optional)
- caching key (vector) with optional meta containing cache options (see `cached` for more details)
- body

Example:
(defcached customer-lifetime-value [db date {:customer/keys [id]}]
 ^{:expire 86400 :refresh 36000}
 [db date id]
 (query-customer-ltv db date id))
sourceraw docstring

invalidateclj

(invalidate cache key)

Invalidate a cache entry.

Invalidate a cache entry.
sourceraw docstring

lookupclj

(lookup cache key)
(lookup cache key f)

Performs cache lookup. Accepts optional function which uses cache key to calculate missing value

Performs cache lookup. Accepts optional function which uses cache key to calculate missing value
sourceraw docstring

lookup-someclj

(lookup-some cache key)

Performs cache lookup for existing value

Performs cache lookup for existing value
sourceraw docstring

putclj

(put cache key val)

Insert/update a cache entry.

Insert/update a cache entry.
sourceraw docstring

put-allclj

(put-all cache m)

Insert/update multiple cache entries. m is a map of key -> value.

Insert/update multiple cache entries.
`m` is a map of key -> value.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close