Permalink
Browse files

Fixed byte[] support for cmd arguments.

  • Loading branch information...
1 parent ca81e77 commit 69d9f88dca6d65d3a2f455312535ea0d4392b6ed @wallrat committed Apr 2, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 src/labs/redis/core.clj
View
@@ -10,6 +10,8 @@
(set! *warn-on-reflection* true)
+(def ^:private byte-array-class (Class/forName "[B"))
+
(defn parse-url [url]
(let [u (java.net.URI. url)
ui (.getUserInfo u)
@@ -56,14 +58,14 @@
(defn value [^Reply reply]
(.getValue reply))
-(let [byte-array-class (Class/forName "[B")]
- (defn ->str
- "Coerces reply into a String."
- [reply]
- (condp instance? reply
- byte-array-class (String. ^bytes reply)
- BulkReply (String. (.bytes ^BulkReply reply))
- java.lang.Object (.toString ^java.lang.Object reply))))
+
+(defn ->str
+ "Coerces reply into a String."
+ [reply]
+ (condp instance? reply
+ byte-array-class (String. ^bytes reply)
+ BulkReply (String. (.bytes ^BulkReply reply))
+ java.lang.Object (.toString ^java.lang.Object reply)))
(defn ->strs [reply]
(map ->str (value reply)))
@@ -85,8 +87,7 @@
(keyword? v) (name v)
(map? v) (map cmd-arg-convert v)
(vector? v) (map cmd-arg-convert v)
- ;; string
- ;; byte[]
+ (instance? byte-array-class v) v
:default (.toString ^Object v)))

0 comments on commit 69d9f88

Please sign in to comment.