Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies update for current clojure library versions #15

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -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.217"}
org.clojure/core.memoize {:mvn/version "1.0.236"}}}
7 changes: 3 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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/"}
Expand Down
12 changes: 6 additions & 6 deletions src/crache/cache.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
(wcar* $ (apply car/set (key-for $ item) (car/freeze @val) args)))
(RedisCache. $))

(evict [_ item]
(wcar* $ (car/del (key-for $ item)))
(RedisCache. $))

(seed [_ base]
(RedisCache. base))

Expand Down
13 changes: 5 additions & 8 deletions src/crache/memo.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
(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 [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))
(memoizer
f
(apply redis-cache-factory conn key-prefix (when ttl [ttl]))))