From 8bf4640d699dc03117e9f156ee441e6460e74f7e Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Tue, 14 Sep 2010 17:48:32 -0700 Subject: [PATCH] Improve docs. --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21971ea15a..c23b7fc0d2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,12 @@ redis - a node redis client This is a Redis client for node. It is designed for node 0.2.1+ and redis 2.0.1+. -Example usage: +Most Redis commands are implemented. The notable exceptions are PUBLISH/SUBSCRIBE, and WATCH/UNWATCH. +These should be coming soon. + +## Usage + +Simple example: var redis = require("redis"), client = redis.createClient(); @@ -30,4 +35,47 @@ This will display: HSET: 1 HKEYS: hashtest 1,hashtest 2 -More instructions will be available as soon as the tests all pass. +Each Redis command is exposed as a function. All functions take two arguments: an array of arguments to send to +Redis, and a callback to invoke when Redis sends a reply. Future versions will support a variable argument +scheme. + +For a list of Redis commands, see [Redis Command Reference](http://code.google.com/p/redis/wiki/CommandReference) + +The commands can be specified in uppercase or lowercase for convenience. `client.get` is the same as `clieint.GET`. + +Minimal parsing is done on the replies. Commands that return a single line reply return JavaScript Strings, +integer replies return JavaScript Numbers, "bulk" replies return node Buffers, and "multi bulk" replies return a +JavaScript Array of ndoe Buffers. + +`MULTI` is supported. The syntax is a little awkward: + + client.multi([ + ["incr", ["multibar"], function (err, res) { + console.log(err || res); + }], + ["incr", ["multifoo"], function (err, res) { + console.log(err || res); + }] + ]); + +`MULTI` takes an Array of 3-element Arrays. The elements are: `command`, `args`, `callback`. +When the commands are all submitted, `EXEC` is called and the callbacks are invoked in order. +If a command is submitted that doesn't pass the syntax check, it will be removed from the +transaction. + +I guess we also need a callback when `MULTI` finishes, in case the last command gets removed from an error. + + +## TODO + +Need to implement PUBLISH/SUBSCRIBE + +Need to implement WATCH/UNWATCH + +Queue new commands that are sent before a connection has been established. + +Sweeten up the syntax to support variable arguments. + +## Also + +Redis is pretty great. This library still needs a lot of work, but it is useful for many things. Patches welcome.