A new ttl-style cache for core-cache that will return expired values on lookup. good if you want to represent a value that changes every 'x' seconds.
[clj-refresh-cache "0.1.0-SNAPSHOT"]
(defn really-expensive [] ...)
;;the refreshing function will return an identity that can be de-referenced in the usual way.
(def every-second (refreshing really-expensive 1000))
;;deref as so
@every-second
;;you can also use the function form
(def memoized (memoize-refreshing really-expensive 1000))
;;call as so
(memoized)
;;alternatively you can use a full core.cache factory
;;which will give you a regular CacheProtocol implementation.
(refresh-cache-factory {:a 100} :ttl 1000)
Copyright © 2014 Dan Stone
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation? These fine people already did:
danstone & Dan StoneEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close