You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-25 00:40:59 +03:00
js highlighting
This commit is contained in:
44
README.md
44
README.md
@@ -773,9 +773,11 @@ Note that this program will not exit cleanly because the client is still connect
|
||||
To execute redis multi-word commands like `SCRIPT LOAD` or `CLIENT LIST` pass
|
||||
the second word as first parameter:
|
||||
|
||||
client.script('load', 'return 1');
|
||||
client.multi().script('load', 'return 1').exec(...);
|
||||
client.multi([['script', 'load', 'return 1']]).exec(...);
|
||||
```js
|
||||
client.script('load', 'return 1');
|
||||
client.multi().script('load', 'return 1').exec(...);
|
||||
client.multi([['script', 'load', 'return 1']]).exec(...);
|
||||
```
|
||||
|
||||
## client.duplicate([options][, callback])
|
||||
|
||||
@@ -790,24 +792,26 @@ blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
|
||||
are used on the same redisClient instance as non-blocking commands, the
|
||||
non-blocking ones may be queued up until after the blocking ones finish.
|
||||
|
||||
var Redis=require('redis');
|
||||
var client = Redis.createClient();
|
||||
var clientBlocking = client.duplicate();
|
||||
```js
|
||||
var Redis=require('redis');
|
||||
var client = Redis.createClient();
|
||||
var clientBlocking = client.duplicate();
|
||||
|
||||
var get = function() {
|
||||
console.log("get called");
|
||||
client.get("any_key",function() { console.log("get returned"); });
|
||||
setTimeout( get, 1000 );
|
||||
};
|
||||
var brpop = function() {
|
||||
console.log("brpop called");
|
||||
clientBlocking.brpop("nonexistent", 5, function() {
|
||||
console.log("brpop return");
|
||||
setTimeout( brpop, 1000 );
|
||||
});
|
||||
};
|
||||
get();
|
||||
brpop();
|
||||
var get = function() {
|
||||
console.log("get called");
|
||||
client.get("any_key",function() { console.log("get returned"); });
|
||||
setTimeout( get, 1000 );
|
||||
};
|
||||
var brpop = function() {
|
||||
console.log("brpop called");
|
||||
clientBlocking.brpop("nonexistent", 5, function() {
|
||||
console.log("brpop return");
|
||||
setTimeout( brpop, 1000 );
|
||||
});
|
||||
};
|
||||
get();
|
||||
brpop();
|
||||
```
|
||||
|
||||
Another reason to use duplicate() is when multiple DBs on the same server are
|
||||
accessed via the redis SELECT command. Each DB could use its own connection.
|
||||
|
||||
Reference in New Issue
Block a user