Skip to content
This repository
Newer
Older
100644 113 lines (79 sloc) 4.327 kb
c10bef23 »
2010-04-05 Updated README
1 # Redis client for Node.js
32b0f9fd » Brian Hammond
2009-06-15 Initial import
2
c10bef23 »
2010-04-05 Updated README
3 ## In a nutshell
7fc74b68 » Brian Hammond
2010-04-01 Big refactor.
4
c10bef23 »
2010-04-05 Updated README
5 - Talk to Redis from Node.js
6 - Fully asynchronous; your code is called back when an operation completes
d073c40e »
2010-04-06 Note about backwards compatibility
7 - [Binary-safe](http://github.com/fictorial/redis-node-client/blob/master/test/test.js#L353-363); uses Node.js Buffer objects for request serialization and reply parsing
c10bef23 »
2010-04-05 Updated README
8 - Client API directly follows Redis' [command specification](http://code.google.com/p/redis/wiki/CommandReference)
9 - *You have to understand how Redis works and the semantics of its command set to most effectively use this client*
10 - Supports Redis' new exciting PUBSUB commands
7fc74b68 » Brian Hammond
2010-04-01 Big refactor.
11
d073c40e »
2010-04-06 Note about backwards compatibility
12 Recent changes completely break backwards compatibility. Sorry, it was time.
13
c10bef23 »
2010-04-05 Updated README
14 ## Synopsis
aa563d35 »
2010-04-05 README updated regarding PUBSUB example
15
bda6edef »
2010-04-06 Fixes for Kiwi
16 When working from a git clone:
17
18 var client = require("./lib/redis-client").createClient();
c10bef23 »
2010-04-05 Updated README
19 var sys = require("sys");
bda6edef »
2010-04-06 Fixes for Kiwi
20 client.stream.addListener("connect", function () {
21 client.info(function (err, info) {
22 if (err) throw new Error(err);
23 sys.puts("Redis Version is: " + info.redis_version);
24 client.close();
25 });
26 });
27
28 When working with a Kiwi-based installation:
29
30 // $ kiwi install redis-client
31
32 var sys = require("sys"),
33 kiwi = require("kiwi"),
34 client = kiwi.require("redis-client").createClient();
35
c10bef23 »
2010-04-05 Updated README
36 client.stream.addListener("connect", function () {
37 client.info(function (err, info) {
38 if (err) throw new Error(err);
39 sys.puts("Redis Version is: " + info.redis_version);
40 client.close();
41 });
42 });
7fc74b68 » Brian Hammond
2010-04-01 Big refactor.
43
827c85c8 »
2010-04-06 Kiwi support
44 - Refer to the many tests in `test/test.js` for many usage examples.
45 - Refer to the `examples/` directory for focused examples.
46
47 ## Installation
48
abf4c4bf »
2010-04-09 works with just-released node v0.1.90
49 This version requires at least `Node.js v0.1.90` and Redis `1.3.8`.
d9d953e2 »
2010-04-06 Add package.json
50
ad801c2d »
2010-04-18 bump version
51 Tested with node `v0.1.91-20-g6e715b8`.
52
827c85c8 »
2010-04-06 Kiwi support
53 You have a number of choices:
54
55 - git clone this repo or download a tarball and simply copy `lib/redis-client.js` into your project
56 - use git submodule
57 - use the [Kiwi](http://github.com/visionmedia/kiwi) package manager for Node.js
d9d953e2 »
2010-04-06 Add package.json
58 - use the [NPM](http://github.com/isaacs/npm) package manager for Node.js
7fc74b68 » Brian Hammond
2010-04-01 Big refactor.
59
01f31152 »
2010-04-06 Note about installation via Kiwi and NPM
60 Please let me know if the package manager "seeds" and/or metadata have issues.
61 Installation via Kiwi or NPM at this point isn't really possible since this repo
3c403ee9 »
2010-04-06 Me talk pretty one day
62 depends on a unreleased version of Node.js.
01f31152 »
2010-04-06 Note about installation via Kiwi and NPM
63
adf5a34e »
2010-04-06 Note about running tests
64 ## Running the tests
65
66 A good way to learn about this client is to read the test code.
67
68 To run the tests, install and run redis on the localhost on port 6379 (defaults).
827c85c8 »
2010-04-06 Kiwi support
69 Then run `node test/test.js [-v|-q]` where `-v` is for "verbose" and `-q` is for "quiet".
adf5a34e »
2010-04-06 Note about running tests
70
827c85c8 »
2010-04-06 Kiwi support
71 $ node test/test.js
deaaa952 »
2010-04-06 Note about running tests
72 ..................................................................
73 ...........................++++++++++++++++++++++++++++++++++++
74
75 [INFO] All tests have passed.
76
77 If you see something like "PSUBSCRIBE: unknown command" then it is time to upgrade
78 your Redis installation.
79
c10bef23 »
2010-04-05 Updated README
80 ## Documentation
7fc74b68 » Brian Hammond
2010-04-01 Big refactor.
81
c10bef23 »
2010-04-05 Updated README
82 There is a method per Redis command. E.g. `SETNX` becomes `client.setnx`.
83
84 For example, the Redis command [INCRBY](http://code.google.com/p/redis/wiki/IncrCommand)
85 is specified as `INCRBY key integer`. Also, the INCRBY spec says that the reply will
86 be "... the new value of key after the increment or decrement."
87
88 This translates to the following client code which increments key 'foo' by 42. If
89 the value at key 'foo' was 0 or non-existent, 'newValue' will take value 42 when
90 the callback function is called.
91
92 client.incrby('foo', 42, function (err, newValue) {
93 // ...
94 });
95
4adaf3f6 »
2010-04-06 Note about parameters and command spec
96 This can get [a little wacky](http://github.com/fictorial/redis-node-client/blob/master/test/test.js#L1093-1097).
97 I'm open to suggestions for improvement here.
98
afd09dcd »
2010-04-06 Note about subscribeTo/unsubscribeFrom
99 Note: for PUBSUB, you should use `subscribeTo` and `unsubscribeFrom` instead of the generated
28ef9d50 »
2010-04-06 Note about subscribeTo/unsubscribeFrom
100 methods for Redis' `SUBSCRIBE` and `UNSUBSCRIBE` commands. See [this](http://github.com/fictorial/redis-node-client/blob/master/lib/redis-client.js#L682-694)
101 and [this](http://github.com/fictorial/redis-node-client/blob/master/examples/subscriber.js#L14).
afd09dcd »
2010-04-06 Note about subscribeTo/unsubscribeFrom
102
c10bef23 »
2010-04-05 Updated README
103 ## Notes
104
105 All commands/requests use the Redis *multi-bulk request* format which will be
106 the only accepted request protocol come Redis 2.0.
107
108 ## Metadata
109
110 - *Author*: Brian Hammond (brian at fictorial dot com) with various patches
111 from nice people everywhere.
112 - *Copyright*: Copyright (C) 2010 Fictorial LLC.
113 - *License*: MIT
32b0f9fd » Brian Hammond
2009-06-15 Initial import
114
Something went wrong with that request. Please try again.