Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Add brpop and brpoplpush
Browse files Browse the repository at this point in the history
  • Loading branch information
arohner committed Feb 16, 2012
1 parent 16d7a44 commit bdf369e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/redis/core.clj
Original file line number Original file line Diff line number Diff line change
@@ -1,14 +1,14 @@
(ns redis.core (ns redis.core
(:refer-clojure :exclude [keys type get set sort]) (:refer-clojure :exclude [keys type get set sort])

;; (:require [clojure.contrib.ns-utils :only (immigrate) :as contrib]) ;; (:require [clojure.contrib.ns-utils :only (immigrate) :as contrib])
(:use [redis.connection :only (with-connection make-non-pooled-connection-pool)] (:use [redis.connection :only (with-connection make-non-pooled-connection-pool)]
[redis.connection-pool :only (make-connection-pool)] [redis.connection-pool :only (make-connection-pool)]
[redis.channel :only (make-direct-channel)] [redis.channel :only (make-direct-channel)]
[redis.vars :only (*pool* *channel*)] [redis.vars :only (*pool* *channel*)]
[redis.protocol :only (*return-byte-arrays?* make-multi-bulk-command)] [redis.protocol :only (*return-byte-arrays?* make-multi-bulk-command)]
[redis.defcommand :only (defcommand defcommands)] [redis.defcommand :only (defcommand defcommands)]

; [redis.commands :only (quit)] ; [redis.commands :only (quit)]
)) ))


Expand Down Expand Up @@ -51,7 +51,7 @@
(config [operation param & value]) (config [operation param & value])
(info [] :inline crlf-to-hash) (info [] :inline crlf-to-hash)
; Connection commands ; Connection commands
(quit [] :inline ) (quit [] :inline )
(auth [password]) (auth [password])
(ping [] :inline) (ping [] :inline)
; Commands operating on all types ; Commands operating on all types
Expand Down Expand Up @@ -96,9 +96,9 @@
(lpop [key]) (lpop [key])
(rpop [key]) (rpop [key])
(blpop [key timeout]) (blpop [key timeout])
; TODO: (brpop [key timeout])
; brpop
(rpoplpush [srckey destkey]) (rpoplpush [srckey destkey])
(brpoplpush [srckey destkey timeout])
; Set commands ; Set commands
(sadd [key member] int-to-bool) (sadd [key member] int-to-bool)
(srem [key member] int-to-bool) (srem [key member] int-to-bool)
Expand Down Expand Up @@ -156,12 +156,12 @@
"Execute all redis commands in body atomically, ie. sandwiched in a "Execute all redis commands in body atomically, ie. sandwiched in a
MULTI/EXEC statement. If an exception is thrown the EXEC command MULTI/EXEC statement. If an exception is thrown the EXEC command
will be terminated by a DISCARD, no operations will be performed and will be terminated by a DISCARD, no operations will be performed and
the exception will be rethrown." the exception will be rethrown."
[& body] [& body]
`(do `(do
(multi) (multi)
(try (try
(do (do
~@body ~@body
(exec)) (exec))
(catch Exception e# (catch Exception e#
Expand Down Expand Up @@ -191,7 +191,7 @@
:desc (recur (conj bulks "DESC") args) :desc (recur (conj bulks "DESC") args)
(throw (Exception. (str "Error parsing arguments to SORT command: Unknown argument: " type)))))))) (throw (Exception. (str "Error parsing arguments to SORT command: Unknown argument: " type))))))))


(defcommand sort [key & args] (defcommand sort [key & args]
(with-meta (with-meta
(apply make-multi-bulk-command "SORT" key (parse-sort-args args)) (apply make-multi-bulk-command "SORT" key (parse-sort-args args))
{:redis-keys [key]})) {:redis-keys [key]}))

0 comments on commit bdf369e

Please sign in to comment.