Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
ACKNOWLEDGEMENTS.md | Tue Nov 24 13:44:46 -0800 2009 | |
| |
LICENSE | Mon Nov 02 17:30:08 -0800 2009 | |
| |
README.md | Tue Dec 01 16:23:21 -0800 2009 | |
| |
ROADMAP.md | Tue Nov 24 13:26:24 -0800 2009 | |
| |
TODO.md | Tue Dec 01 16:23:21 -0800 2009 | |
| |
counter-example.js | Tue Nov 24 13:35:22 -0800 2009 | |
| |
redisclient.js | Fri Dec 04 17:14:28 -0800 2009 | |
| |
test.js | Fri Dec 04 18:06:22 -0800 2009 |
redis-node-client
A Redis client implementation for Node.js which runs atop Google V8.
This project lets you access a Redis instance using server-side JavaScript.
Asynchronicity
Node.js does not block on I/O operations.
This means that while a typical Redis client might have code that accesses a Redis server in a blocking call, Node.js-based code cannot.
Typical Redis client (e.g. Python):
foo = client.get('counter')
This Node.js-based Redis client:
var sys = require("sys");
var redis = require("./redis");
var client = new redis.Client();
client.connect(learn_to_count);
function learn_to_count () {
client.incr('counter').addCallback(function (value) {
sys.puts("counter is now " + value);
client.close();
});
}
Running this example, we'd see:
$ node counter-example.js
counter is now 1
$ node counter-example.js
counter is now 2
$ node counter-example.js
counter is now 3
That is, you must supply a callback function that is called when Redis returns, even if Redis queries are extremely fast.
A potential upside to this slightly awkward requirement is that you can enjoy the benefits of pipelining many Redis queries in a non-blocking way. Redis returns replies for requests in the order received.
See the test.js file as a good example of this.
Status
- The full Redis 1.1 command specification is supported.
- All tests pass using Redis HEAD at commit (09f6f7020952cd93e178da11e66e36f8a98398d1; Dec 1 2009)
- All tests pass using Node.js v0.1.20-3-g5b1a535 (Dec 1 2009)
- See the TODO file for known issues.
Testing
To test:
- fire up redis-server on 127.0.0.1:6379 (the default)
- install node.js
- run
node test.js
Author
Brian Hammond, Fictorial (brian at fictorial dot com)
Copyright
Copyright (C) 2009 Fictorial LLC
License
See LICENSE (it's MIT; go nuts).







