@@ -437,19 +437,19 @@ protocol. Any commands where client state is saved on the Redis server, e.g.
437
437
` *SUBSCRIBE ` or the blocking ` BL* ` commands will * NOT* work with ` .unref() ` .
438
438
439
439
``` js
440
- var redis = require (" redis" )
441
- var client = redis .createClient ()
440
+ var redis = require (" redis" );
441
+ var client = redis .createClient ();
442
442
443
443
/*
444
444
Calling unref() will allow this program to exit immediately after the get
445
445
command finishes. Otherwise the client would hang as long as the
446
446
client-server connection is alive.
447
447
*/
448
- client .unref ()
449
- client .get (" foo" , function (err , value ){
450
- if (err) throw (err)
451
- console .log (value)
452
- })
448
+ client .unref ();
449
+ client .get (" foo" , function (err , value ) {
450
+ if (err) throw (err);
451
+ console .log (value);
452
+ });
453
453
```
454
454
455
455
## Friendlier hash commands
@@ -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.
@@ -957,7 +961,7 @@ ReplyError: ERR wrong number of arguments for 'set' command
957
961
958
962
## How to Contribute
959
963
- Open a pull request or an issue about what you want to implement / change. We're glad for any help!
960
- - Please be aware that we'll only accept fully tested code.
964
+ - Please be aware that we'll only accept fully tested code.
961
965
962
966
## Contributors
963
967
0 commit comments