Skip to content

Commit 92839c6

Browse files
committed
Merge pull request #812 from fintura/readme
Update readme
2 parents f611a87 + 37866b0 commit 92839c6

File tree

1 file changed

+55
-101
lines changed

1 file changed

+55
-101
lines changed

README.md

Lines changed: 55 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ redis - a node.js redis client
44
[![Build Status](https://travis-ci.org/NodeRedis/node_redis.png)](https://travis-ci.org/NodeRedis/node_redis)
55
[![Coverage Status](https://coveralls.io/repos/NodeRedis/node_redis/badge.svg?branch=)](https://coveralls.io/r/NodeRedis/node_redis?branch=)
66

7-
This is a complete Redis client for node.js. It supports all Redis commands,
8-
including many recently added commands like EVAL from experimental Redis server
9-
branches.
7+
This is a complete Redis client for node.js. It supports all Redis commands,
8+
including many recently added commands.
109

1110
Install with:
1211

@@ -89,11 +88,11 @@ client.get("missingkey", function(err, reply) {
8988

9089
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands)
9190

92-
The commands can be specified in uppercase or lowercase for convenience. `client.get()` is the same as `client.GET()`.
91+
The commands can be specified in uppercase or lowercase for convenience. `client.get()` is the same as `client.GET()`.
9392

94-
Minimal parsing is done on the replies. Commands that return a single line reply return JavaScript Strings,
93+
Minimal parsing is done on the replies. Commands that return a single line reply return JavaScript Strings,
9594
integer replies return JavaScript Numbers, "bulk" replies return node Buffers, and "multi bulk" replies return a
96-
JavaScript Array of node Buffers. `HGETALL` returns an Object with Buffers keyed by the hash keys.
95+
JavaScript Array of node Buffers. `HGETALL` returns an Object with Buffers keyed by the hash keys.
9796

9897
# API
9998

@@ -104,21 +103,21 @@ JavaScript Array of node Buffers. `HGETALL` returns an Object with Buffers keye
104103
### "ready"
105104

106105
`client` will emit `ready` once a connection is established to the Redis server and the server reports
107-
that it is ready to receive commands. Commands issued before the `ready` event are queued,
106+
that it is ready to receive commands. Commands issued before the `ready` event are queued,
108107
then replayed just before this event is emitted.
109108

110109
### "connect"
111110

112111
`client` will emit `connect` at the same time as it emits `ready` unless `client.options.no_ready_check`
113-
is set. If this options is set, `connect` will be emitted when the stream is connected, and then
112+
is set. If this options is set, `connect` will be emitted when the stream is connected, and then
114113
you are free to try to send commands.
115114

116115
### "error"
117116

118117
`client` will emit `error` when encountering an error connecting to the Redis server.
119118

120-
Note that "error" is a special event type in node. If there are no listeners for an
121-
"error" event, node will exit. This is usually what you want, but it can lead to some
119+
Note that "error" is a special event type in node. If there are no listeners for an
120+
"error" event, node will exit. This is usually what you want, but it can lead to some
122121
cryptic error messages like this:
123122

124123
mjr:~/work/node_redis (master)$ node example.js
@@ -143,8 +142,8 @@ It would be nice to distinguish these two cases.
143142
### "drain"
144143

145144
`client` will emit `drain` when the TCP connection to the Redis server has been buffering, but is now
146-
writable. This event can be used to stream commands in to Redis and adapt to backpressure. Right now,
147-
you need to check `client.command_queue.length` to decide when to reduce your send rate. Then you can
145+
writable. This event can be used to stream commands in to Redis and adapt to backpressure. Right now,
146+
you need to check `client.command_queue.length` to decide when to reduce your send rate. Then you can
148147
resume sending when you get `drain`.
149148

150149
### "idle"
@@ -163,22 +162,22 @@ port and host are probably fine and you don't need to supply any arguments. `cre
163162

164163
`options` is an object with the following possible properties:
165164

166-
* `parser`: which Redis protocol reply parser to use. Defaults to `hiredis` if that module is installed.
165+
* `parser`: which Redis protocol reply parser to use. Defaults to `hiredis` if that module is installed.
167166
This may also be set to `javascript`.
168-
* `return_buffers`: defaults to `false`. If set to `true`, then all replies will be sent to callbacks as node Buffer
167+
* `return_buffers`: defaults to `false`. If set to `true`, then all replies will be sent to callbacks as node Buffer
169168
objects instead of JavaScript Strings.
170169
* `detect_buffers`: default to `false`. If set to `true`, then replies will be sent to callbacks as node Buffer objects
171170
if any of the input arguments to the original command were Buffer objects.
172171
This option lets you switch between Buffers and Strings on a per-command basis, whereas `return_buffers` applies to
173172
every command on a client.
174173
* `socket_nodelay`: defaults to `true`. Whether to call setNoDelay() on the TCP stream, which disables the
175-
Nagle algorithm on the underlying socket. Setting this option to `false` can result in additional throughput at the
176-
cost of more latency. Most applications will want this set to `true`.
174+
Nagle algorithm on the underlying socket. Setting this option to `false` can result in additional throughput at the
175+
cost of more latency. Most applications will want this set to `true`.
177176
* `socket_keepalive` defaults to `true`. Whether the keep-alive functionality is enabled on the underlying socket.
178177
* `no_ready_check`: defaults to `false`. When a connection is established to the Redis server, the server might still
179-
be loading the database from disk. While loading, the server not respond to any commands. To work around this,
180-
`node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command
181-
indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event.
178+
be loading the database from disk. While loading, the server not respond to any commands. To work around this,
179+
`node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command
180+
indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event.
182181
Setting `no_ready_check` to `true` will inhibit this check.
183182
* `enable_offline_queue`: defaults to `true`. By default, if there is no active
184183
connection to the redis server, commands are added to a queue and are executed
@@ -219,20 +218,20 @@ client.end();
219218
## client.auth(password, callback)
220219

221220
When connecting to Redis servers that require authentication, the `AUTH` command must be sent as the
222-
first command after connecting. This can be tricky to coordinate with reconnections, the ready check,
223-
etc. To make this easier, `client.auth()` stashes `password` and will send it after each connection,
224-
including reconnections. `callback` is invoked only once, after the response to the very first
221+
first command after connecting. This can be tricky to coordinate with reconnections, the ready check,
222+
etc. To make this easier, `client.auth()` stashes `password` and will send it after each connection,
223+
including reconnections. `callback` is invoked only once, after the response to the very first
225224
`AUTH` command sent.
226225
NOTE: Your call to `client.auth()` should not be inside the ready handler. If
227226
you are doing this wrong, `client` will emit an error that looks
228227
something like this `Error: Ready check failed: ERR operation not permitted`.
229228

230229
## client.end()
231230

232-
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
231+
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
233232
If you want to exit cleanly, call `client.quit()` to send the `QUIT` command after you have handled all replies.
234233

235-
This example closes the connection to the Redis server before the replies have been read. You probably don't
234+
This example closes the connection to the Redis server before the replies have been read. You probably don't
236235
want to do this:
237236

238237
```js
@@ -276,7 +275,7 @@ When dealing with hash values, there are a couple of useful exceptions to this.
276275

277276
### client.hgetall(hash)
278277

279-
The reply from an HGETALL command will be converted into a JavaScript Object by `node_redis`. That way you can interact
278+
The reply from an HGETALL command will be converted into a JavaScript Object by `node_redis`. That way you can interact
280279
with the responses using JavaScript syntax.
281280

282281
Example:
@@ -317,7 +316,7 @@ client.HMSET(key1, "0123456789", "abcdefghij", "some manner of key", "a type of
317316

318317
## Publish / Subscribe
319318

320-
Here is a simple example of the API for publish / subscribe. This program opens two
319+
Here is a simple example of the API for publish / subscribe. This program opens two
321320
client connections, subscribes to a channel on one of them, and publishes to that
322321
channel on the other:
323322

@@ -347,7 +346,7 @@ client1.subscribe("a nice channel");
347346
```
348347

349348
When a client issues a `SUBSCRIBE` or `PSUBSCRIBE`, that connection is put into a "subscriber" mode.
350-
At that point, only commands that modify the subscription set are valid. When the subscription
349+
At that point, only commands that modify the subscription set are valid. When the subscription
351350
set is empty, the connection is put back into regular mode.
352351

353352
If you need to send regular commands to Redis while in subscriber mode, just open another connection.
@@ -369,30 +368,30 @@ name as `channel`, and the message Buffer as `message`.
369368

370369
### "subscribe" (channel, count)
371370

372-
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are passed the
371+
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are passed the
373372
channel name as `channel` and the new count of subscriptions for this client as `count`.
374373

375374
### "psubscribe" (pattern, count)
376375

377-
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners are passed the
376+
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners are passed the
378377
original pattern as `pattern`, and the new count of subscriptions for this client as `count`.
379378

380379
### "unsubscribe" (channel, count)
381380

382-
Client will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners are passed the
383-
channel name as `channel` and the new count of subscriptions for this client as `count`. When
381+
Client will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners are passed the
382+
channel name as `channel` and the new count of subscriptions for this client as `count`. When
384383
`count` is 0, this client has left subscriber mode and no more subscriber events will be emitted.
385384

386385
### "punsubscribe" (pattern, count)
387386

388-
Client will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command. Listeners are passed the
389-
channel name as `channel` and the new count of subscriptions for this client as `count`. When
387+
Client will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command. Listeners are passed the
388+
channel name as `channel` and the new count of subscriptions for this client as `count`. When
390389
`count` is 0, this client has left subscriber mode and no more subscriber events will be emitted.
391390

392391
## client.multi([commands])
393392

394393
`MULTI` commands are queued up until an `EXEC` is issued, and then all commands are run atomically by
395-
Redis. The interface in `node_redis` is to return an individual `Multi` object by calling `client.multi()`.
394+
Redis. The interface in `node_redis` is to return an individual `Multi` object by calling `client.multi()`.
396395

397396
```js
398397
var redis = require("./index"),
@@ -426,8 +425,8 @@ client.multi()
426425

427426
### Multi.exec( callback )
428427

429-
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects share all of the
430-
same command methods as `client` objects do. Commands are queued up inside the `Multi` object
428+
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects share all of the
429+
same command methods as `client` objects do. Commands are queued up inside the `Multi` object
431430
until `Multi.exec()` is invoked.
432431

433432
The `callback` of `.exec()` will get invoked with two arguments:
@@ -484,8 +483,8 @@ client.multi([
484483
Redis supports the `MONITOR` command, which lets you see all commands received by the Redis server
485484
across all client connections, including from other client libraries and other computers.
486485

487-
After you send the `MONITOR` command, no other commands are valid on that connection. `node_redis`
488-
will emit a `monitor` event for every new monitor message that comes across. The callback for the
486+
After you send the `MONITOR` command, no other commands are valid on that connection. `node_redis`
487+
will emit a `monitor` event for every new monitor message that comes across. The callback for the
489488
`monitor` event takes a timestamp from the Redis server and an array of command arguments.
490489

491490
Here is a simple example:
@@ -521,7 +520,7 @@ The `versions` key contains an array of the elements of the version string for e
521520

522521
## redis.print()
523522

524-
A handy callback function for displaying return values when testing. Example:
523+
A handy callback function for displaying return values when testing. Example:
525524

526525
```js
527526
var redis = require("redis"),
@@ -581,36 +580,36 @@ the second word as first parameter:
581580

582581
## client.send_command(command_name, args, callback)
583582

584-
Used internally to send commands to Redis. For convenience, nearly all commands that are published on the Redis
585-
Wiki have been added to the `client` object. However, if I missed any, or if new commands are introduced before
583+
Used internally to send commands to Redis. For convenience, nearly all commands that are published on the Redis
584+
Wiki have been added to the `client` object. However, if I missed any, or if new commands are introduced before
586585
this library is updated, you can use `send_command()` to send arbitrary commands to Redis.
587586

588-
All commands are sent as multi-bulk commands. `args` can either be an Array of arguments, or omitted.
587+
All commands are sent as multi-bulk commands. `args` can either be an Array of arguments, or omitted.
589588

590589
## client.connected
591590

592591
Boolean tracking the state of the connection to the Redis server.
593592

594593
## client.command_queue.length
595594

596-
The number of commands that have been sent to the Redis server but not yet replied to. You can use this to
595+
The number of commands that have been sent to the Redis server but not yet replied to. You can use this to
597596
enforce some kind of maximum queue depth for commands while connected.
598597

599598
Don't mess with `client.command_queue` though unless you really know what you are doing.
600599

601600
## client.offline_queue.length
602601

603-
The number of commands that have been queued up for a future connection. You can use this to enforce
602+
The number of commands that have been queued up for a future connection. You can use this to enforce
604603
some kind of maximum queue depth for pre-connection commands.
605604

606605
## client.retry_delay
607606

608-
Current delay in milliseconds before a connection retry will be attempted. This starts at `250`.
607+
Current delay in milliseconds before a connection retry will be attempted. This starts at `250`.
609608

610609
## client.retry_backoff
611610

612-
Multiplier for future retry timeouts. This should be larger than 1 to add more time between retries.
613-
Defaults to 1.7. The default initial connection retry is 250, so the second retry will be 425, followed by 723.5, etc.
611+
Multiplier for future retry timeouts. This should be larger than 1 to add more time between retries.
612+
Defaults to 1.7. The default initial connection retry is 250, so the second retry will be 425, followed by 723.5, etc.
614613

615614
### Commands with Optional and Keyword arguments
616615

@@ -648,7 +647,7 @@ operations. As pipelining happens naturally from shared connections, overall
648647
efficiency goes up.
649648

650649
Here are typical results of `multi_bench.js` which is similar to
651-
`redis-benchmark` from the Redis distribution. It uses 5 concurrent connections
650+
`redis-benchmark` from the Redis distribution. It uses 5 concurrent connections
652651
and shows the difference between pipelines of 1 and 50.
653652

654653
JavaScript parser:
@@ -697,7 +696,7 @@ If the `hiredis` npm module is installed, `node_redis` will use it by default.
697696
Otherwise, the pure JavaScript parser will be used.
698697

699698
If you use `hiredis`, be sure to rebuild it whenever you upgrade your version of
700-
node. There are mysterious failures that can happen between node and native
699+
node. There are mysterious failures that can happen between node and native
701700
code modules after a node upgrade.
702701

703702
Most users find that the JS parser is faster than the `hiredis` parser. Because
@@ -742,65 +741,20 @@ hiredis parser:
742741

743742
## TODO
744743

745-
Better tests for auth, disconnect/reconnect, and all combinations thereof.
746-
747-
Stream large set/get values into and out of Redis. Otherwise the entire value must be in node's memory.
748-
749-
Performance can be better for very large values.
750-
751-
I think there are more performance improvements left in there for smaller values, especially for large lists of small values.
744+
1. 100% coverage
745+
2. More performance improvements
746+
3. Stream large set/get values into and out of Redis. Otherwise the entire value must be in node's memory.
747+
4. Performance can be better for very large values in the js parser.
752748

753749
## How to Contribute
754-
- open a pull request and then wait for feedback (if
755-
[DTrejo](http://github.com/dtrejo) does not get back to you within 2 days,
756-
comment again with indignation!)
750+
- open a pull request and then wait for feedback
757751

758752
## Contributors
759-
Many people have have added features and fixed bugs in `node_redis`.
760-
761-
Ordered by date of first contribution.
762-
[Auto-generated](http://github.com/dtrejo/node-authors) on Wed Jul 25 2012 19:14:59 GMT-0700 (PDT).
763-
764-
- [Matt Ranney aka `mranney`](https://github.com/mranney)
765-
- [Tim-Smart aka `tim-smart`](https://github.com/tim-smart)
766-
- [Tj Holowaychuk aka `visionmedia`](https://github.com/visionmedia)
767-
- [rick aka `technoweenie`](https://github.com/technoweenie)
768-
- [Orion Henry aka `orionz`](https://github.com/orionz)
769-
- [Aivo Paas aka `aivopaas`](https://github.com/aivopaas)
770-
- [Hank Sims aka `hanksims`](https://github.com/hanksims)
771-
- [Paul Carey aka `paulcarey`](https://github.com/paulcarey)
772-
- [Pieter Noordhuis aka `pietern`](https://github.com/pietern)
773-
- [nithesh aka `nithesh`](https://github.com/nithesh)
774-
- [Andy Ray aka `andy2ray`](https://github.com/andy2ray)
775-
- [unknown aka `unknowdna`](https://github.com/unknowdna)
776-
- [Dave Hoover aka `redsquirrel`](https://github.com/redsquirrel)
777-
- [Vladimir Dronnikov aka `dvv`](https://github.com/dvv)
778-
- [Umair Siddique aka `umairsiddique`](https://github.com/umairsiddique)
779-
- [Louis-Philippe Perron aka `lp`](https://github.com/lp)
780-
- [Mark Dawson aka `markdaws`](https://github.com/markdaws)
781-
- [Ian Babrou aka `bobrik`](https://github.com/bobrik)
782-
- [Felix Geisendörfer aka `felixge`](https://github.com/felixge)
783-
- [Jean-Hugues Pinson aka `undefined`](https://github.com/undefined)
784-
- [Maksim Lin aka `maks`](https://github.com/maks)
785-
- [Owen Smith aka `orls`](https://github.com/orls)
786-
- [Zachary Scott aka `zzak`](https://github.com/zzak)
787-
- [TEHEK Firefox aka `TEHEK`](https://github.com/TEHEK)
788-
- [Isaac Z. Schlueter aka `isaacs`](https://github.com/isaacs)
789-
- [David Trejo aka `DTrejo`](https://github.com/DTrejo)
790-
- [Brian Noguchi aka `bnoguchi`](https://github.com/bnoguchi)
791-
- [Philip Tellis aka `bluesmoon`](https://github.com/bluesmoon)
792-
- [Marcus Westin aka `marcuswestin2`](https://github.com/marcuswestin2)
793-
- [Jed Schmidt aka `jed`](https://github.com/jed)
794-
- [Dave Peticolas aka `jdavisp3`](https://github.com/jdavisp3)
795-
- [Trae Robrock aka `trobrock`](https://github.com/trobrock)
796-
- [Shankar Karuppiah aka `shankar0306`](https://github.com/shankar0306)
797-
- [Ignacio Burgueño aka `ignacio`](https://github.com/ignacio)
798-
799-
Thanks.
753+
Many people have have added features and fixed bugs in `node_redis`. Thanks to all of them!
800754

801755
## LICENSE - "MIT License"
802756

803-
Copyright (c) 2010 Matthew Ranney, http://ranney.com/
757+
Copyright (c) 2015 Matthew Ranney, http://ranney.com/
804758

805759
Permission is hereby granted, free of charge, to any person
806760
obtaining a copy of this software and associated documentation

0 commit comments

Comments
 (0)