anchor.diff:     (connection-stream connection))
     (force-output (connection-stream connection))
     (translate-result (read-reply connection) octets nil nil))
  +
  +;; Transactions
  +
  +(define-command multi "Begin a transaction")
  +(define-command exec "Commit transaction")
  +(define-command discard "Rollback transaction")
  +
  +;; TODO: Publish/Subscribe
  +
  +;; Persistence control commands
  +
  +(define-command save "Synchronously save the database on disk.")
  +(define-command bgsave "Asynchronously save the database on disk.")
  +(define-command lastsave "Return the UNIX timestamp of the last successful save.")
  +(define-command shutdown :no-read "Synchronously save the database on disk, then shutdown the server.")
  +(define-command bgrewriteaof "Rewrite the append only file in the background when it gets too big.")
  +
  +;; Remove server control commands
  +
  +(define-command info "Provide information and statistics about the server")
  +(define-command slaveof (host :string) (port :integer) "Change the replication settings.")
  +(define-command config "Configure a redis server at runtime.")
  +
  +;; Undocumented in command reference
  +
  +(define-command ping "Ping the redis server.")
  
positive.code:                               (write-sequence ,(car x) ,out)))))
                  (write-sequence #(13 10) ,out))))
          `(defun ,name ,inputs
             (write-sequence ,octets-form (connection-stream ,connection))
             (force-output (connection-stream ,connection))
             ,(if no-read
                  `(values)
                  `(translate-result (read-reply ,connection) ,octets ,booleanize ,split)))))))
  
  (define-command quit :no-read)
  (define-command auth (password :string))
  (define-command ping)
  (define-command set (key :key) (value :bulk))
  (define-command get (key :key))
  (define-command getset (key :key) (value :bulk))
  (define-command mget (keys :keys))
  (define-command setnx :boolean (key :key) (value :bulk))
  (define-command incr (key :key))
  (define-command incrby (key :key) (integer :integer))
  (define-command decr (key :key))
  (define-command decrby (key :key) (integer :integer))
  (define-command exists :boolean (key :key))
  (define-command del :boolean (key :key))
  (define-command type (key :key))
  (define-command keys :split (pattern :key))
  (define-command randomkey)
  (define-command rename (oldname :key) (newname :key))
  (define-command renamenx :boolean (oldname :key) (newname :key))
  (define-command dbsize)
  (define-command expire :boolean (key :key) (seconds :integer))
  (define-command ttl (key :key))
  (define-command rpush (key :key) (value :bulk))
  (define-command lpush (key :key) (value :bulk))
  (define-command llen (key :key))
  (define-command lrange (key :key) (start :integer) (end :integer))
  (define-command ltrim (key :key) (start :integer) (end :integer))
  (define-command lindex (key :key) (index :integer))
  (define-command lset (key :key) (index :integer) (value :bulk))
  (define-command lrem (key :key) (count :integer) (value :bulk))
  (define-command lpop (key :key))
  (define-command rpop (key :key))
  (define-command sadd :boolean (key :key) (member :bulk))
  (define-command srem :boolean (key :key) (member :bulk))
  (define-command spop (key :key))
  (define-command smove :boolean (srckey :key) (dstkey :key))
  (define-command scard (key :key))
  (define-command sismember :boolean (key :key) (member :key))
  (define-command sinter (keys :keys))
  (define-command sinterstore (dstkey :key) (keys :keys))
  (define-command sunion (keys :keys))
  (define-command sunionstore (dstkey :key) (keys :keys))
  (define-command sdiff (keys :keys))
  (define-command sdiffstore (dstkey :key) (keys :keys))
  (define-command smembers (key :key))
  (define-command zadd (key :key) (score :integer) (member :bulk))
  (define-command zrem (key :key) (member :bulk))
  (define-command zincrby (key :key) (increment :integer) (member :bulk))
  (define-command zrange (key :key) (start :integer) (end :integer))
  (define-command zrevrange (key :key) (start :integer) (end :integer))
  (define-command zrangebyscore (key :key) (min :integer) (max :integer))
  (define-command zcard (key :key))
  (define-command zscore (key :key) (element :bulk))
  (define-command zremrangebyscore (key :key) (min :integer) (max :integer))
  (define-command select (index :integer))
  (define-command move :boolean (key :key) (dbindex :integer))
  (define-command flushdb)
  (define-command flushall)
  (define-command save)
  (define-command bgsave)
  (define-command lastsave)
  (define-command shutdown :no-read)
  (define-command info)
  (define-command slaveof (host :string) (port :integer))
  
  (defun sort (key &key (connection *connection*) octets order limit-start limit-end by get alpha)
    (write-sequence
     (babel-streams:with-output-to-sequence (out)
       (write-sequence "SORT " out)
  
negative.code: (defmacro define-command (name &rest spec)
    (let ((booleanize (when (eq (car spec) :boolean) (pop spec)))
          (split (when (eq (car spec) :split) (pop spec)))
          (no-read (when (eq (car spec) :no-read) (pop spec)))
          (docstring (car (last spec)))
          (spec (butlast spec)))
      (push (symbol-name name) spec)
      (let ((connection (gensym)) (octets (gensym)) (out (gensym)))
        (let ((inputs (cl:append (mapcan (lambda (x)
                                           (when (consp x)
                                             (list (car x))))
                                         spec)
                                 `(&key ((:connection ,connection) *connection*))
                                 (unless no-read
                                   `(((:octets ,octets))))))
              (octets-form
               `(babel-streams:with-output-to-sequence (,out)
                  ,@(loop for first-time = t then nil
  