From 2aa1d13a5ffc4ba6ebec9bf2bbd123e757820d2b Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Wed, 28 Jul 2021 16:47:58 +0200 Subject: [PATCH 1/9] Adjusted namespace form --- src/crache/memo.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index d8ff63e..bc13c24 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -1,7 +1,7 @@ (ns crache.memo (:import [clojure.core.memoize PluggableMemoization]) - (:use [crache.cache :only [redis-cache-factory]] - [clojure.core.memoize :only [build-memoizer]])) + (:require [crache.cache :refer [redis-cache-factory]] + [clojure.core.memoize :refer [build-memoizer]])) (defn memo-redis From edd1299461143bb84d2577af3f8f5a85056a691c Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Wed, 28 Jul 2021 16:56:11 +0200 Subject: [PATCH 2/9] Dependencies update --- deps.edn | 4 ++++ project.clj | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 deps.edn diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..584f024 --- /dev/null +++ b/deps.edn @@ -0,0 +1,4 @@ + {:deps {org.clojure/clojure {:mvn/version "1.10.2"} + com.taoensso/carmine {:mvn/version "3.1.0"} + org.clojure/core.cache {:mvn/version "1.0.207"} + org.clojure/core.memoize {:mvn/version "1.0.236"}}} diff --git a/project.clj b/project.clj index 3a55929..13175ce 100644 --- a/project.clj +++ b/project.clj @@ -2,10 +2,9 @@ :description "Redis-backed caching and memoization, following core.cache and core.memoize" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :url "http://github.com/strongh/crache" - :dependencies [[org.clojure/clojure "1.4.0"] - [com.taoensso/carmine "2.7.0"] - [org.clojure/core.cache "0.6.4"] - [org.clojure/core.memoize "0.5.6"]] + :plugins [[lein-tools-deps "0.4.5"]] + :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn] + :lein-tools-deps/config {:config-files [:install :user :project]} :mirrors {"clojure" {:url "https://build.clojure.org/releases/"} "clojure-snapshots" {:url "https://build.clojure.org/snapshots/"} From 17d51d17a64abd668283173c53889ca96d602efa Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Wed, 28 Jul 2021 16:59:34 +0200 Subject: [PATCH 3/9] Dependencies update --- src/crache/memo.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index bc13c24..54b35c0 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -1,5 +1,4 @@ (ns crache.memo - (:import [clojure.core.memoize PluggableMemoization]) (:require [crache.cache :refer [redis-cache-factory]] [clojure.core.memoize :refer [build-memoizer]])) From f92aa5dc2180b146858641f4efa00b8172755872 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 14 Oct 2021 16:35:43 +0200 Subject: [PATCH 4/9] Update memo.clj --- src/crache/memo.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index 54b35c0..98ccea6 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -7,5 +7,5 @@ [f conn key-prefix & [ttl]] (build-memoizer #(clojure.core.memoize.PluggableMemoization. - %1 (apply redis-cache-factory conn key-prefix (when ttl [ttl]))) + (apply redis-cache-factory conn key-prefix (when ttl [ttl])) %1) f)) From 9fba31b1e8c9bfd6418d70c76e58bd98e53af2de Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 14 Oct 2021 16:56:43 +0200 Subject: [PATCH 5/9] Update memo.clj --- src/crache/memo.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index 98ccea6..54b35c0 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -7,5 +7,5 @@ [f conn key-prefix & [ttl]] (build-memoizer #(clojure.core.memoize.PluggableMemoization. - (apply redis-cache-factory conn key-prefix (when ttl [ttl])) %1) + %1 (apply redis-cache-factory conn key-prefix (when ttl [ttl]))) f)) From 159a43a768fdfea4cd144fa39ef9ad333a7ee646 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 14 Oct 2021 17:03:19 +0200 Subject: [PATCH 6/9] fix: use modern memoizer function --- src/crache/cache.clj | 10 +++++----- src/crache/memo.clj | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/crache/cache.clj b/src/crache/cache.clj index c3e82e7..235f9e8 100644 --- a/src/crache/cache.clj +++ b/src/crache/cache.clj @@ -15,23 +15,23 @@ (lookup [_ item not-found] (delay (or (wcar* $ (car/get (key-for $ item))) not-found))) - + (has? [_ item] (= 1 (wcar* $ (car/exists (key-for $ item))))) - + (hit [_ item] (RedisCache. $)) - + (miss [_ item val] (let [args (when-let [t (:ttl $)] ["ex" t]) val (if (delay? val) @val val)] (wcar* $ (apply car/set (key-for $ item) (car/serialize val) args))) (RedisCache. $)) - + (evict [_ item] (wcar* $ (car/del (key-for $ item))) (RedisCache. $)) - + (seed [_ base] (RedisCache. base)) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index 54b35c0..f751363 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -1,11 +1,9 @@ (ns crache.memo (:require [crache.cache :refer [redis-cache-factory]] - [clojure.core.memoize :refer [build-memoizer]])) - + [clojure.core.memoize :refer [memoizer]])) (defn memo-redis - [f conn key-prefix & [ttl]] - (build-memoizer - #(clojure.core.memoize.PluggableMemoization. - %1 (apply redis-cache-factory conn key-prefix (when ttl [ttl]))) - f)) + [f conn key-prefix $ [ttl]] + (memoizer + f + (apply redis-cache-factory conn key-prefix (when ttl [ttl])))) From 7e917a354f6edec04c4246e7470f7570ebbaa522 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 14 Oct 2021 18:09:18 +0200 Subject: [PATCH 7/9] fix: use modern memoizer function --- src/crache/memo.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crache/memo.clj b/src/crache/memo.clj index f751363..1987c54 100644 --- a/src/crache/memo.clj +++ b/src/crache/memo.clj @@ -3,7 +3,7 @@ [clojure.core.memoize :refer [memoizer]])) (defn memo-redis - [f conn key-prefix $ [ttl]] + [f conn key-prefix & [ttl]] (memoizer f (apply redis-cache-factory conn key-prefix (when ttl [ttl])))) From 555cdc22c7d69f5179e8f1a35752418b66766820 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 14 Oct 2021 19:06:01 +0200 Subject: [PATCH 8/9] fix: use modern memoizer function --- src/crache/cache.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crache/cache.clj b/src/crache/cache.clj index 235f9e8..91ec02e 100644 --- a/src/crache/cache.clj +++ b/src/crache/cache.clj @@ -25,7 +25,7 @@ (miss [_ item val] (let [args (when-let [t (:ttl $)] ["ex" t]) val (if (delay? val) @val val)] - (wcar* $ (apply car/set (key-for $ item) (car/serialize val) args))) + (wcar* $ (apply car/set (key-for $ item) (car/freeze (val)) args))) (RedisCache. $)) (evict [_ item] From 6d5721f15d6d470969098ef19737109b08aa6dc0 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Fri, 15 Oct 2021 10:27:48 +0200 Subject: [PATCH 9/9] test fix for memoize interaction --- deps.edn | 2 +- src/crache/cache.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.edn b/deps.edn index 584f024..197317d 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ {:deps {org.clojure/clojure {:mvn/version "1.10.2"} com.taoensso/carmine {:mvn/version "3.1.0"} - org.clojure/core.cache {:mvn/version "1.0.207"} + org.clojure/core.cache {:mvn/version "1.0.217"} org.clojure/core.memoize {:mvn/version "1.0.236"}}} diff --git a/src/crache/cache.clj b/src/crache/cache.clj index 91ec02e..02e9d56 100644 --- a/src/crache/cache.clj +++ b/src/crache/cache.clj @@ -25,7 +25,7 @@ (miss [_ item val] (let [args (when-let [t (:ttl $)] ["ex" t]) val (if (delay? val) @val val)] - (wcar* $ (apply car/set (key-for $ item) (car/freeze (val)) args))) + (wcar* $ (apply car/set (key-for $ item) (car/freeze @val) args))) (RedisCache. $)) (evict [_ item]