@@ -773,9 +773,11 @@ Note that this program will not exit cleanly because the client is still connect
773
773
To execute redis multi-word commands like ` SCRIPT LOAD ` or ` CLIENT LIST ` pass
774
774
the second word as first parameter:
775
775
776
- client.script('load', 'return 1');
777
- client.multi().script('load', 'return 1').exec(...);
778
- client.multi([['script', 'load', 'return 1']]).exec(...);
776
+ ``` js
777
+ client .script (' load' , ' return 1' );
778
+ client .multi ().script (' load' , ' return 1' ).exec (... );
779
+ client .multi ([[' script' , ' load' , ' return 1' ]]).exec (... );
780
+ ```
779
781
780
782
## client.duplicate([ options] [ , callback ] )
781
783
@@ -790,24 +792,26 @@ blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
790
792
are used on the same redisClient instance as non-blocking commands, the
791
793
non-blocking ones may be queued up until after the blocking ones finish.
792
794
793
- var Redis=require('redis');
794
- var client = Redis.createClient();
795
- var clientBlocking = client.duplicate();
796
-
797
- var get = function() {
798
- console.log("get called");
799
- client.get("any_key",function() { console.log("get returned"); });
800
- setTimeout( get, 1000 );
801
- };
802
- var brpop = function() {
803
- console.log("brpop called");
804
- clientBlocking.brpop("nonexistent", 5, function() {
805
- console.log("brpop return");
806
- setTimeout( brpop, 1000 );
807
- });
808
- };
809
- get();
810
- brpop();
795
+ ``` js
796
+ var Redis= require (' redis' );
797
+ var client = Redis .createClient ();
798
+ var clientBlocking = client .duplicate ();
799
+
800
+ var get = function () {
801
+ console .log (" get called" );
802
+ client .get (" any_key" ,function () { console .log (" get returned" ); });
803
+ setTimeout ( get, 1000 );
804
+ };
805
+ var brpop = function () {
806
+ console .log (" brpop called" );
807
+ clientBlocking .brpop (" nonexistent" , 5 , function () {
808
+ console .log (" brpop return" );
809
+ setTimeout ( brpop, 1000 );
810
+ });
811
+ };
812
+ get ();
813
+ brpop ();
814
+ ```
811
815
812
816
Another reason to use duplicate() is when multiple DBs on the same server are
813
817
accessed via the redis SELECT command. Each DB could use its own connection.
0 commit comments