anchor.diff:  ;; conditions
   
   (define-condition redis-error (error)
  -  ((message
  -    :initarg  :message
  -    :initform (error "Must provide Redis error message.")))
  -  (:report (lambda (c stream)
  -             (declare (ignore c))
  -             (format stream "Redis error: ~a"
  -                     (slot-value condition 'message)))))
  -
  -(defun redis-error (message)
  -  "Signal specialised error."
  -  (error 'redis-error :message message))
  +  ((message :initarg :message :reader redis-error-message))
  +  (:report (lambda (e stream)
  +             (format stream "Redis error: ~A" (redis-error-message e))))
  +  (:documentation "This is the condition type that will be used to
  +signal virtually all Redis-related errors."))
  +
  +(define-condition redis-connection-error (redis-error)
  +  ()
  +  (:documentation "Conditions of this type are signaled when
  +errors occur that break the connection stream.  They offer a
  +:reconnect restart."))
  +
  +(define-condition redis-error-reply (redis-error)
  +  ()
  +  (:documentation "Raised when an error reply is received from the
  +Redis server."))
  +
  +(define-condition redis-protocol-error (redis-error)
  +  ()
  +  (:documentation "Raised when a Redis protocol error is detected."))
  +
  +(defun wrap-connection-error (e)
  +  (make-instance 'redis-connection-error
  +                 :message (princ-to-string e)))
   
   ;; connect
   
   (defun redis-connect ()
  -  (setf *redis-stream* (make-flexi-stream
  -                        (socket-stream
  -                         (socket-connect *redis-host*
  -                                         *redis-port*
  -                                         :element-type 'octet))
  -                        :external-format *redis-external-format*
  -                        :element-type 'octet)))
  +  (handler-case
  +      (setf *redis-stream* (make-flexi-stream
  +                            (socket-stream
  +                             (socket-connect *redis-host*
  +                                             *redis-port*
  +                                             :element-type 'octet))
  +                            :external-format *redis-external-format*
  +                            :element-type 'octet))
  +    ((or socket-error stream-error)
  +        (e)
  +      (restart-case (error (wrap-connection-error e))
  +        (:reconnect () :report "Try to reconnect." (redis-connect))))))
  +  
   
   ;; outgoing
   
  
positive.code: <_: args /> is the <_:fun tell /> arguments, <_:arg docstring /> ~
  is the function's doc itself."
    (let ((cmd-name (intern (format nil "~a-~a" *cmd-prefix* cmd))))
      (with-unique-names (call-command)
        `(progn
           (defun ,cmd-name (,@args)
             ,docstring
             (labels ((,call-command ()
                        (restart-case
                            (progn
                              ,(if-it (position '&rest args)
                                      `(apply #'tell ,cmd-type
                                              ',cmd
                                              ,@(subseq args 0 it)                   
                                              ,(nth (1+ it) args))
                                      `(tell ,cmd-type ',cmd ,@args))
                              (expect ,reply-type))
                          (reconnect-and-retry
                              ()
                            :report "Try to reconnect and execute the command again."
                            (redis-connect)
                            (,call-command)))))
               (,call-command)))
           (export ',cmd-name :redis)))))
  
  ;;; end
negative.code: (defparameter *redis-port* 6379
    "Default Redis connection port.")
  
  (defparameter *redis-external-format* (make-external-format :utf-8 :eol-style :crlf))
  
  (defvar *echo-p* nil
    "Whether the server-client communication should be echoed to the
  