(cache-find cache cache-key)
Read from cache, without trying to set.
Read from cache, without trying to set.
(cached cache-container env cache-key f)
Try to read some value from a cache, otherwise run and cache it.
cache-container is a keyword for the cache container name, consider that the environment has multiple cache atoms. If the cache-container key is not present in the env, the cache will be ignored and will always run f.
cache-key is how you decide, in that cache container, what key should be used for this cache try.
f needs to a function of zero arguments.
Example:
(cached ::my-cache {::my-cache (atom {})} [3 :foo]
(fn [] (run-expensive-operation)))
Try to read some value from a cache, otherwise run and cache it. cache-container is a keyword for the cache container name, consider that the environment has multiple cache atoms. If the cache-container key is not present in the env, the cache will be ignored and will always run f. cache-key is how you decide, in that cache container, what key should be used for this cache try. f needs to a function of zero arguments. Example: (cached ::my-cache {::my-cache (atom {})} [3 :foo] (fn [] (run-expensive-operation)))
(-cache-find this cache-key)
Implement a way to read a cache key from the cache. If there is a hit, you must return a map entry for the result, otherwise return nil. The map-entry can make the distinction between a miss (nil return) vs a value with a miss (a map-entry with a value of nil)
Implement a way to read a cache key from the cache. If there is a hit, you must return a map entry for the result, otherwise return nil. The map-entry can make the distinction between a miss (nil return) vs a value with a miss (a map-entry with a value of nil)
(-cache-lookup-or-miss this cache-key f)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close