(through cache item)
(through value-fn cache item)
(through wrap-fn value-fn cache item)
The basic hit/miss logic for the cache system. Expects a wrap function and
value function. The wrap function takes the value function and the item in question
and is expected to run the value function with the item whenever a cache
miss occurs. The intent is to hide any cache-specific cells from leaking
into the cache logic itelf.
Source
(defn through
"The basic hit/miss logic for the cache system. Expects a wrap function and
value function. The wrap function takes the value function and the item in question
and is expected to run the value function with the item whenever a cache
miss occurs. The intent is to hide any cache-specific cells from leaking
into the cache logic itelf."
([cache item] (through default-wrapper-fn identity cache item))
([value-fn cache item] (through default-wrapper-fn value-fn cache item))
([wrap-fn value-fn cache item]
(if (clojure.core.cache/has? cache item)
(clojure.core.cache/hit cache item)
(clojure.core.cache/miss cache item (wrap-fn #(value-fn %) item)))))