2 level caching (In memory + memcache) for Clojure.
Nippy is used internally to serialize values in memcache. full.cache 1.0.1 is
using nippy 2.10.0
, full.cache 1.1.0
is using nippy 2.13.0
.
full.cache 1.2.0
is using nippy 2.14.0
and prefixes cache keys with n2.14.0-
Memcached server url can be set in the yaml config file(s), it's loaded via full.core:
memcache-url: localhost:11211
All methods in full.cache
follow naming conventions:
-
methods starting with
r
will only use remote cache (rget
, for example) -
methods starting with
l
will only use localc cache (lget
, for example) -
methods without
r
orl
prefix will use both caches (on writes - writing to both, on reads - using local first & fallbacking to remote) -
methods ending with a
>
return a core.async channel with the value -
methods not ending with a
>
are blocking
full.cache
provides methods for working with cache in any of desired
combinations (local only, remote only, or both)
; method that tries to load a cool value & fallbacks to the loader method
; if value is absent.
(get-or-load>
"cool-value"
(fn []
(go
(clojure.core.async/<! (clojure.core.async/timeout 3000))
42))
100)
; read from remote cache only
(rget "cool-value")
; fetching or loading from local cache only
(lget-or-load>
"cool-value"
(fn []
(go
(clojure.core.async/<! (clojure.core.async/timeout 3000))
42))
100)