-
Notifications
You must be signed in to change notification settings - Fork 38
Home
A fast and robust Common Lisp client for Redis database
- start Redis server
(require 'cl-redis)
- (optinally)
(setf redis:*redis-port* <actual-port>)
(redis:redis-connect)
-
(redis:ping)
=> “PONG” - …
(redis:redis-disconnect)
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)
If *debug*
is set to t
, all input and output will be echoed to *standard-output*
.