Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Dec 5, 2012
2 parents cdaf83a + 21b7a66 commit 77b71b1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Current [semantic](http://semver.org/) version:

```clojure
[com.taoensso/carmine "1.0.1"]
[com.taoensso/carmine "1.1.0"]
```

# Carmine, a Clojure Redis client & message queue
Expand Down Expand Up @@ -37,7 +37,7 @@ Carmine is an attempt to **cohesively bring together the best bits from each cli
Depend on Carmine in your `project.clj`:

```clojure
[com.taoensso/carmine "1.0.1"]
[com.taoensso/carmine "1.1.0"]
```

and `require` the library:
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 com.taoensso/carmine "1.0.1"
(defproject com.taoensso/carmine "1.1.0"
:description "Clojure Redis client & message queue"
:url "https://github.com/ptaoussanis/carmine"
:license {:name "Eclipse Public License"}
Expand All @@ -7,7 +7,7 @@
[commons-codec/commons-codec "1.6"]
[org.clojure/data.json "0.2.1"]
[com.taoensso/timbre "1.0.0"]
[com.taoensso/nippy "1.0.0"]]
[com.taoensso/nippy "1.0.1"]]
:profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.0-alpha3"]]}
Expand Down
6 changes: 5 additions & 1 deletion src/taoensso/carmine.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(:refer-clojure :exclude [time get set keys type sync sort eval])
(:require [clojure.string :as str]
[taoensso.carmine
(utils :as utils)
(protocol :as protocol)
(connections :as conns)
(commands :as commands)])
Expand Down Expand Up @@ -99,12 +100,15 @@
* Singular category names (\"account\" rather than \"accounts\").
* Dashes for long names (\"email-address\" rather than \"emailAddress\", etc.)."
[& prefix-parts]
(let [join-parts (fn [parts] (str/join ":" (map name (filter identity parts))))
(let [join-parts (fn [parts] (str/join ":" (map utils/scoped-name
(filter identity parts))))
prefix (when (seq prefix-parts) (str (join-parts prefix-parts) ":"))]
(fn [& parts] (str prefix (join-parts parts)))))

(comment ((make-keyfn :foo :bar) :baz "qux")
((make-keyfn :foo.bar/baz) :qux)
((make-keyfn) :foo :bar)
((make-keyfn) :foo.bar/baz :qux)
((make-keyfn) nil "foo"))

(defn preserve
Expand Down
15 changes: 14 additions & 1 deletion src/taoensso/carmine/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,17 @@
(defn version-sufficient?
[version-str min-version-str]
(try (>= (version-compare version-str min-version-str) 0)
(catch Exception _ false)))
(catch Exception _ false)))

(defn scoped-name
"Like `name` but includes namespace in string when present."
[x]
(if (string? x) x
(let [name (.getName ^clojure.lang.Named x)]
(if-let [ns (.getNamespace ^clojure.lang.Named x)]
(str ns "/" name)
name))))

(comment (map scoped-name [:foo :foo/bar :foo.bar/baz])
(time (dotimes [_ 10000] (name :foo)))
(time (dotimes [_ 10000] (scoped-name :foo))))

0 comments on commit 77b71b1

Please sign in to comment.