Skip to content

Commit 983cc69

Browse files
Merge pull request #2 from BrianRossmajer/BrianRossmajer-patch-2
Update README.md
2 parents 6c118c3 + fc2c0dd commit 983cc69

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,38 +618,33 @@ the second word as first parameter:
618618

619619
Duplicate all current options and return a new redisClient instance. All options passed to the duplicate function are going to replace the original option.
620620

621-
An example of when to use duplicate() would be to accomodate the connection-
621+
One example of when to use duplicate() would be to accomodate the connection-
622622
blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
623623
are used on the same redisClient instance as non-blocking commands, the
624624
non-blocking ones may be queued up until after the blocking ones finish.
625625

626626
var Redis=require('redis');
627627
var client = Redis.createClient();
628+
var clientBlocking = client.duplicate();
629+
628630
var get = function() {
629631
console.log("get called");
630632
client.get("any_key",function() { console.log("get returned"); });
631633
setTimeout( get, 1000 );
632634
};
633635
var brpop = function() {
634636
console.log("brpop called");
635-
client.brpop("nonexistent", 5, function() {
637+
clientBlocking.brpop("nonexistent", 5, function() {
636638
console.log("brpop return");
637639
setTimeout( brpop, 1000 );
638640
});
639641
};
640642
get();
641643
brpop();
642644

643-
These two repeating functions will interfere with each other -- the `get`s will
644-
not return until after the `brpop` returns. This can be fixed by keeping the
645-
blocking calls separate using `client.duplicate()`, eg:
646-
647-
...
648-
var clientBlocking = client.duplicate();
649-
var brpop = function() {
650-
console.log("brpop called");
651-
clientBlocking.brpop( ...
652-
645+
Another reason to use duplicate() is when multiple DBs on the same server are
646+
accessed via the redis SELECT command. Each DB could use its own connection.
647+
653648
## client.send_command(command_name[, [args][, callback]])
654649

655650
All Redis commands have been added to the `client` object. However, if new commands are introduced before this library is updated,

0 commit comments

Comments
 (0)