mirror of
https://github.com/fluencelabs/redis
synced 2025-06-20 12:36:31 +00:00
client libraries updated
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
;(add-classpath "file:///Users/ragge/Projects/clojure/redis-clojure/src/")
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
(ns redis
|
||||
(:refer-clojure :exclude [get set type keys sort])
|
||||
(:use redis.internal))
|
||||
|
||||
;(set! *warn-on-reflection* true)
|
||||
|
||||
(defmacro with-server
|
||||
"Evaluates body in the context of a new connection to a Redis server
|
||||
then closes the connection.
|
||||
@ -100,6 +100,7 @@
|
||||
;; Set commands
|
||||
(sadd [key member] :bulk int-to-bool)
|
||||
(srem [key member] :bulk int-to-bool)
|
||||
(spop [key] :inline)
|
||||
(smove [srckey destkey member] :bulk int-to-bool)
|
||||
(scard [key] :inline)
|
||||
(sismember [key member] :bulk int-to-bool)
|
||||
@ -122,6 +123,7 @@
|
||||
(bgsave [] :inline)
|
||||
(lastsave [] :inline int-to-date)
|
||||
(shutdown [] :inline)
|
||||
;; Remote control
|
||||
(info [] :inline string-to-map)
|
||||
;;(monitor [] :inline))
|
||||
)
|
||||
|
@ -39,7 +39,8 @@
|
||||
(let [{:keys [host port timeout]} server
|
||||
socket (Socket. #^String host #^Integer port)]
|
||||
(doto socket
|
||||
(.setTcpNoDelay true))))
|
||||
(.setTcpNoDelay true)
|
||||
(.setKeepAlive true))))
|
||||
|
||||
(defn with-server*
|
||||
[server-spec func]
|
||||
@ -99,8 +100,7 @@
|
||||
|
||||
(defn reply-type
|
||||
([#^BufferedReader reader]
|
||||
(let [type (char (.read reader))]
|
||||
type)))
|
||||
(char (.read reader))))
|
||||
|
||||
(defmulti parse-reply reply-type :default :unknown)
|
||||
|
||||
|
@ -214,20 +214,25 @@
|
||||
(redis/lset "list" -1 "test3")
|
||||
(is (= "test3" (redis/lindex "list" 2))))
|
||||
|
||||
|
||||
;; TBD
|
||||
(deftest lrem
|
||||
(is (thrown? Exception (redis/lrem "foo" 0 "bar")))
|
||||
(is (= 0 (redis/lrem "list" 0 ""))))
|
||||
(is (= 0 (redis/lrem "newlist" 0 "")))
|
||||
(is (= 1 (redis/lrem "list" 1 "two")))
|
||||
(is (= 1 (redis/lrem "list" 42 "three")))
|
||||
(is (= 1 (redis/llen "list"))))
|
||||
|
||||
|
||||
(deftest lpop
|
||||
(is (thrown? Exception (redis/lpop "foo")))
|
||||
(is (= "one" (redis/lpop "list"))))
|
||||
(is (= nil (redis/lpop "newlist")))
|
||||
(is (= "one" (redis/lpop "list")))
|
||||
(is (= 2 (redis/llen "list"))))
|
||||
|
||||
(deftest rpop
|
||||
(is (thrown? Exception (redis/rpop "foo")))
|
||||
(is (= "three" (redis/rpop "list"))))
|
||||
(is (= nil (redis/rpop "newlist")))
|
||||
(is (= "three" (redis/rpop "list")))
|
||||
(is (= 2 (redis/llen "list"))))
|
||||
|
||||
;;
|
||||
;; Set commands
|
||||
@ -242,11 +247,16 @@
|
||||
|
||||
(deftest srem
|
||||
(is (thrown? Exception (redis/srem "foo" "bar")))
|
||||
(is (thrown? Exception (redis/srem "newset" "member")))
|
||||
(is (= false (redis/srem "newset" "member")))
|
||||
(is (= true (redis/srem "set" "two")))
|
||||
(is (= false (redis/sismember "set" "two")))
|
||||
(is (= false (redis/srem "set" "blahonga"))))
|
||||
|
||||
(deftest spop
|
||||
(is (thrown? Exception (redis/spop "foo" "bar")))
|
||||
(is (= nil (redis/spop "newset")))
|
||||
(is (contains? #{"one" "two" "three"} (redis/spop "set"))))
|
||||
|
||||
(deftest smove
|
||||
(is (thrown? Exception (redis/smove "foo" "set" "one")))
|
||||
(is (thrown? Exception (redis/smove "set" "foo" "one")))
|
||||
|
@ -4,11 +4,6 @@
|
||||
(:import [java.io StringReader BufferedReader]))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;
|
||||
;; Helpers
|
||||
;;
|
||||
|
Reference in New Issue
Block a user