Permalink
Browse files

Support for multiple response parsers and hiredis C library from Piet…

…er Noordhuis.

Return Strings instead of Buffers by default.
Empty nested mb reply bug fix.
  • Loading branch information...
1 parent 36c40ee commit b81da6d8fc34e8afa80c3ec4f865c5497f3baca9 @mranney mranney committed Dec 9, 2010
Showing with 23 additions and 15 deletions.
  1. +14 −8 README.md
  2. +2 −1 changelog.md
  3. +7 −6 multi_bench.js
View
@@ -7,10 +7,10 @@ Install with:
npm install redis
-By default, a pure JavaScript reply parser is used. This is clever and portable, but not as fast for large responses as `hiredis` from the
-Redis distribution. To use the `hiredis`, do:
+For portability, a pure JavaScript reply parser is used by default. Pieter Noordhuis has provided a binding to the
+official `hiredis` C library, which is non-blocking and fast. To use `hiredis`, do:
- npm install hiredis
+ npm install hiredis redis
If `hiredis` is installed, `node_redis` will use it by default.
@@ -20,7 +20,7 @@ If `hiredis` is installed, `node_redis` will use it by default.
number of sites.
`node_redis` was originally written to replace `node-redis-client` which hasn't been updated in a while, and no longer works
-on recent versions of node.
+with recent versions of node.
## Usage
@@ -116,7 +116,7 @@ Not very useful in diagnosing the problem, but if your program isn't ready to ha
it is probably the right thing to just exit.
`client` will also emit `error` if an exception is thrown inside of `node_redis` for whatever reason.
-In the future, there will be a better way to distinguish these error types.
+It would be nice to distinguish these two cases.
### "end"
@@ -133,12 +133,18 @@ resume sending when you get `drain`.
`client` will emit `idle` when there are no outstanding commands that are awaiting a response.
-## redis.createClient(port, host)
+## redis.createClient(port, host, options)
Create a new client connection. `port` defaults to `6379` and `host` defaults
-to `127.0.0.1`. If you have Redis running on the same computer as node, then the defaults are probably fine.
+to `127.0.0.1`. If you have `redis-server` running on the same computer as node, then the defaults for
+port and host are probably fine. `options` in an object with the following possible properties:
-`createClient` returns a `RedisClient` object that is named `client` in all of the examples here.
+* `parser`: which Redis protocol reply parser to use. Defaults to `hiredis` if that module is installed.
+ This may also be set to `javascript`.
+* `return_buffers`: defaults to false. If set to `true`, then bulk data replies will be returned as node Buffer
+ objects instead of JavaScript Strings.
+
+`createClient()` returns a `RedisClient` object that is named `client` in all of the examples here.
## client.end()
View
@@ -3,8 +3,9 @@ Changelog
## v0.4.0 - December 5, 2010
-Support for multiple response parsers and hiredis.
+Support for multiple response parsers and hiredis C library from Pieter Noordhuis.
Return Strings instead of Buffers by default.
+Empty nested mb reply bug fix.
## v0.3.9 - November 30, 2010
View
@@ -2,11 +2,15 @@ var redis = require("./index"),
num_clients = parseInt(process.argv[2]) || 50,
active_clients = 0,
clients = new Array(num_clients),
- num_requests = 20000,
+ num_requests = 2000,
issued_requests = 0,
latency = new Array(num_requests),
tests = [],
- test_start;
+ test_start,
+ client_options = {
+ parser: "javascript",
+ return_buffers: false
+ };
redis.debug_mode = false;
@@ -54,10 +58,7 @@ function create_clients(callback) {
var client, connected = active_clients;
while (active_clients < num_clients) {
- client = clients[active_clients++] = redis.createClient(6379, "127.0.0.1", {
- parser: "hiredis",
- return_buffers: false
- });
+ client = clients[active_clients++] = redis.createClient(6379, "127.0.0.1", client_options);
client.on("connect", function() {
// Fire callback when all clients are connected
connected += 1;

0 comments on commit b81da6d

Please sign in to comment.