Skip to content
vseloved edited this page Sep 13, 2010 · 17 revisions

cl-redis

A fast and robust Common Lisp client for Redis database

dependencies

usage

  1. start Redis server
  2. (require 'cl-redis)
  3. (optinally) (setf redis:*redis-port* <actual-port>)
  4. (redis:redis-connect)
  5. (redis:ping) => “PONG
  6. (redis:redis-disconnect)

extending

There are 2 generic functions: tell and expect which implement different style of Redis interactions according to the “protocol”: . Tell specifies how the request to Redis is formatted and expect — how the response is handled. The best way to implement another method on expect is usually with def-expect-method, that arranges reading of data from the socket and provides a variable _raw, that holds the read string. For example:
(def-expect-method :ok (assert (string= _raw "OK")) _raw)

Redis operations are defined as functions with def-cmd for which only types of interactions and arguments should be provided. Def-cmd prefixes all the defined functions’ names with *cmd-prefix*, that defaults to 'red. (Note, that setting of *cmd-prefix* will has it’s effects at compile time). The example of command definition is below:
(def-cmd KEYS "Return all the keys matching a given pattern" :inline (pattern) :list)
(see commands.lisp for all defined commands)

debugging, testing and error recovery

If *debug* is set to t, all input and output will be echoed to *standard-output*.

Clone this wiki locally