(cached f)
Accepts a function and creates cached version of it which uses Caffeine Loading Cache.
Cache expiration and refresh time (in seconds) can be provided as :expire
and :refresh
meta to function.
Example:
(cached ^{:expire 86400 :refresh 36000}
(fn [db id] (query db id)))
Accepts a function and creates cached version of it which uses Caffeine Loading Cache. Cache expiration and refresh time (in seconds) can be provided as `:expire` and `:refresh` meta to function. Example: ``` (cached ^{:expire 86400 :refresh 36000} (fn [db id] (query db id))) ```
(defcached name args cache-key & fn-body)
Creates a function which uses Caffeine Loading Cache under the hood. Function declaration is similar to defn:
:expire
and :refresh
for cache expiration and refresh time (in seconds)(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 - args (vector) - caching key (vector) with optional meta containing cache options `:expire` and `:refresh` for cache expiration and refresh time (in seconds) - body Example: ``` (defcached customer-lifetime-value [db date {:customer/keys [id]}] ^{:expire 86400 :refresh 36000} [db date id] (query-customer-ltv db date id)) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close