
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.09 KB | hits: 8 | expires: Never
(in-package :redis)
(def-cmd WATCH (key) :status "Watch a key.")
(def-cmd UNWATCH () :status "Unwatch any watched keys.")
;; Better support for bulk-multi bodies, more stable
(def-expect-method :multi
(let ((n (parse-integer reply)))
(unless (= n -1)
(loop :repeat n
:collect (expect :anything)))))
;; HACK: Using this expectation for now until a cleaner pass
(def-cmd UNSUBSCRIBE (&rest chans) :unsubscribe
"Drain the channel messages then return the list of unsubscriptions.")
(defmethod expect ((type (eql :unsubscribe)))
"Override the unsubscribe return to drain the pending messages,
then read all of the unsubscriptions until zero rather than panic
and fall down crying. >:["
(let (unsubs (discarded 0))
(do ((current (redis:expect :multi) (redis:expect :multi)))
((and (string-equal (first current) :unsubscribe)
(= 0 (parse-integer (car (last current)))))
(progn (push current unsubs)
(values unsubs discarded)))
(if (string-equal (first current) :unsubscribe)
(push current unsubs)
(incf discarded)))))