Liking cljdoc? Tell your friends :D

fmnoise.coldbrew


build-cacheclj

(build-cache options & [loader])

Builds Caffeine Loading Cache with given options and optional cache loader. Supported options are: :expire - expiration time after write (in seconds) :expire-after-access - expiration time after access (in seconds) :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)

Builds Caffeine Loading Cache with given options and optional cache loader. Supported options are:
`:expire` - expiration time after write (in seconds)
`:expire-after-access` - expiration time after access (in seconds)
`: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`)
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

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

fetchclj

(fetch cache key)
(fetch cache key condition-fn computation-fn args)

Performs cache lookup and optional conditional value computation if value is missing

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

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

× close