diff --git a/project.clj b/project.clj index 71f9e8a..3c98403 100644 --- a/project.clj +++ b/project.clj @@ -15,7 +15,7 @@ :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.reader "0.10.0"] - [com.taoensso/encore "2.64.1"] + [com.taoensso/encore "2.67.1"] [org.iq80.snappy/snappy "0.4"] [org.tukaani/xz "1.5"] [net.jpountz.lz4/lz4 "1.3"]] diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index 4c7421d..6e8dd95 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -20,8 +20,8 @@ LazySeq IRecord ISeq])) (if (vector? enc/encore-version) - (enc/assert-min-encore-version [2 52 1]) - (enc/assert-min-encore-version 2.52)) + (enc/assert-min-encore-version [2 67 1]) + (enc/assert-min-encore-version 2.67)) (comment (set! *unchecked-math* :warn-on-boxed) @@ -238,9 +238,9 @@ ;; TODO Switch to thread-local proxies? -(enc/defonce* ^:dynamic *freeze-fallback* "(fn [data-output x]), nil => default" nil) -(enc/defonce* ^:dynamic *custom-readers* "{ (fn [data-input])}" nil) -(enc/defonce* ^:dynamic *auto-freeze-compressor* +(enc/defonce ^:dynamic *freeze-fallback* "(fn [data-output x]), nil => default" nil) +(enc/defonce ^:dynamic *custom-readers* "{ (fn [data-input])}" nil) +(enc/defonce ^:dynamic *auto-freeze-compressor* "(fn [byte-array])->compressor used by `(freeze {:compressor :auto}), nil => default" nil) @@ -1553,5 +1553,6 @@ ;;;; Deprecated -(enc/defonce* ^:dynamic *final-freeze-fallback* "DEPRECATED" nil) -(def freeze-fallback-as-str "DEPRECATED" write-unfreezable) +(enc/deprecated + (enc/defonce ^:dynamic *final-freeze-fallback* "DEPRECATED" nil) + (def freeze-fallback-as-str "DEPRECATED" write-unfreezable)) diff --git a/src/taoensso/nippy/utils.clj b/src/taoensso/nippy/utils.clj index 47108e0..2e00cab 100644 --- a/src/taoensso/nippy/utils.clj +++ b/src/taoensso/nippy/utils.clj @@ -8,16 +8,17 @@ ;; Unfortunately the only ~reliable way we can tell if something's ;; really serializable/readable is to actually try a full roundtrip. -(defn- memoize-type-test [test-fn] - (let [cache (atom {})] ; { } - (fn [x] - (let [t (type x) - ;; This is a bit hackish, but no other obvious solutions (?): - cacheable? (not (re-find #"__\d+" (str t))) ; gensym form - test (fn [] (try (test-fn x) (catch Exception _ false)))] - (if cacheable? - @(enc/swap-val! cache t #(if % % (delay (test)))) - (test)))))) +(let [swap-cache! @#'enc/-swap-cache!] ; TODO Public with newer Encore + (defn- memoize-type-test [test-fn] + (let [cache (atom {})] ; { } + (fn [x] + (let [t (type x) + ;; This is a bit hackish, but no other obvious solutions (?): + cacheable? (not (re-find #"__\d+" (str t))) ; gensym form + test (fn [] (try (test-fn x) (catch Exception _ false)))] + (if cacheable? + @(swap-cache! cache t #(if % % (delay (test)))) + (test))))))) (def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true))) (def serializable?