diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..964b8c1 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,6 @@ +# 2.0.0 + +Breaking change: Serialization of memcache values (in the remote cache) +changed to newer version of nippy. This means memcached would need to be +cleared, or `:throw?` would need to be set to `false` temporarily for the cache +to reset itself to newly serialized values. diff --git a/README.md b/README.md index 51eca01..470e5bf 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ 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`. ## Configuration diff --git a/project.clj b/project.clj index 1236b1e..33452f1 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject fullcontact/full.cache "1.0.2-SNAPSHOT" +(defproject fullcontact/full.cache "1.1.0-SNAPSHOT" :description "In-memory + memcache caching for Clojure with async loading." :url "https://github.com/fullcontact/full.cache" :license {:name "Eclipse Public License - v 1.0" @@ -8,7 +8,7 @@ :dependencies [[org.clojure/clojure "1.8.0"] [net.jodah/expiringmap "0.4.1"] [net.spy/spymemcached "2.12.2"] - [com.taoensso/nippy "2.10.0"] + [com.taoensso/nippy "2.13.0"] [fullcontact/full.core "0.10.1" :exclusions [org.clojure/clojurescript]] [fullcontact/full.async "0.9.0"]] diff --git a/src/full/cache.clj b/src/full/cache.clj index 28c782e..7ca1a77 100644 --- a/src/full/cache.clj +++ b/src/full/cache.clj @@ -97,18 +97,22 @@ (defn rget [k & {:keys [throw?]}] (when @client - (let [v (try + (let [raw-v (try (.get @client k) (catch Exception e (if throw? (throw e) - (log/warn k "not retrieved from cache due to" e))))] + (log/warn k "not retrieved from cache due to" e)))) + v (try + (and raw-v (nippy/thaw raw-v)) + (catch Exception e + (if throw? + (throw e) + (log/warn "Failed to deserialize bytes for key" k))))] (if v (log/debug "Cache hit:" k) (log/debug "Cache miss:" k)) - (if v - (nippy/thaw v) - v)))) + v))) (defn rset ([k v] (rset k v 0)) diff --git a/test/full/t_cache.clj b/test/full/t_cache.clj index c605c89..f0d7aff 100644 --- a/test/full/t_cache.clj +++ b/test/full/t_cache.clj @@ -155,4 +155,4 @@ ( "k4" loader 1)) => (every-checker nil - (fn [_] (= 1 @load-cnt)))))) \ No newline at end of file + (fn [_] (= 1 @load-cnt))))))