Skip to content

Commit

Permalink
Upgrade nippy to 2.13.0
Browse files Browse the repository at this point in the history
* The motivation here is actually to update the transient "com.taoensso/encore" dependency to a much newer version
* nippy 2.10.0 depends on a version of encore that dates back 2 years ago, 71 releases old x.x
* This treats deserialization like any other potential error caused during fetch, and throws if :throw? is true
* The theory here is, if upgrading from an old version, you'd get lots of cache misses until the cache slowly resets itself from old values
  • Loading branch information
Skiggz authored and skazhy committed Nov 6, 2017
1 parent 791e054 commit 6300656
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]]
Expand Down
14 changes: 9 additions & 5 deletions src/full/cache.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/full/t_cache.clj
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@
(<!! (cache/lget-or-load> "k4" loader 1))
=> (every-checker
nil
(fn [_] (= 1 @load-cnt))))))
(fn [_] (= 1 @load-cnt))))))

0 comments on commit 6300656

Please sign in to comment.