Skip to content

Commit 66d5a50

Browse files
authored
Merge pull request #1307 from ConjureLabs/master
Updated README for syntax highlighting
2 parents 1a4c410 + 2a15fc8 commit 66d5a50

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

README.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,19 @@ protocol. Any commands where client state is saved on the Redis server, e.g.
437437
`*SUBSCRIBE` or the blocking `BL*` commands will *NOT* work with `.unref()`.
438438

439439
```js
440-
var redis = require("redis")
441-
var client = redis.createClient()
440+
var redis = require("redis");
441+
var client = redis.createClient();
442442

443443
/*
444444
Calling unref() will allow this program to exit immediately after the get
445445
command finishes. Otherwise the client would hang as long as the
446446
client-server connection is alive.
447447
*/
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+
});
453453
```
454454

455455
## Friendlier hash commands
@@ -773,9 +773,11 @@ Note that this program will not exit cleanly because the client is still connect
773773
To execute redis multi-word commands like `SCRIPT LOAD` or `CLIENT LIST` pass
774774
the second word as first parameter:
775775

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+
```
779781

780782
## client.duplicate([options][, callback])
781783

@@ -790,24 +792,26 @@ blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
790792
are used on the same redisClient instance as non-blocking commands, the
791793
non-blocking ones may be queued up until after the blocking ones finish.
792794

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+
```
811815

812816
Another reason to use duplicate() is when multiple DBs on the same server are
813817
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
957961

958962
## How to Contribute
959963
- 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.
961965

962966
## Contributors
963967

0 commit comments

Comments
 (0)