You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-09-11 18:50:46 +03:00
chore: use standard
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
var redis = require('redis');
|
||||
var client = redis.createClient();
|
||||
var setSize = 20;
|
||||
var redis = require('redis')
|
||||
var client = redis.createClient()
|
||||
var setSize = 20
|
||||
|
||||
client.sadd('bigset', 'a member');
|
||||
client.sadd('bigset', 'another member');
|
||||
client.sadd('bigset', 'a member')
|
||||
client.sadd('bigset', 'another member')
|
||||
|
||||
while (setSize > 0) {
|
||||
client.sadd('bigset', 'member ' + setSize);
|
||||
setSize -= 1;
|
||||
client.sadd('bigset', 'member ' + setSize)
|
||||
setSize -= 1
|
||||
}
|
||||
|
||||
// multi chain with an individual callback
|
||||
@@ -17,33 +17,37 @@ client.multi()
|
||||
.scard('bigset')
|
||||
.smembers('bigset')
|
||||
.keys('*', function (err, replies) {
|
||||
client.mget(replies, console.log);
|
||||
if (err) throw err
|
||||
client.mget(replies, console.log)
|
||||
})
|
||||
.dbsize()
|
||||
.exec(function (err, replies) {
|
||||
console.log('MULTI got ' + replies.length + ' replies');
|
||||
replies.forEach(function (reply, index) {
|
||||
console.log('Reply ' + index + ': ' + reply.toString());
|
||||
});
|
||||
});
|
||||
if (err) throw err
|
||||
console.log('MULTI got ' + replies.length + ' replies')
|
||||
replies.forEach(function (reply, index) {
|
||||
console.log('Reply ' + index + ': ' + reply.toString())
|
||||
})
|
||||
})
|
||||
|
||||
client.mset('incr thing', 100, 'incr other thing', 1, console.log);
|
||||
client.mset('incr thing', 100, 'incr other thing', 1, console.log)
|
||||
|
||||
// start a separate multi command queue
|
||||
var multi = client.multi();
|
||||
multi.incr('incr thing', console.log);
|
||||
multi.incr('incr other thing', console.log);
|
||||
var multi = client.multi()
|
||||
multi.incr('incr thing', console.log)
|
||||
multi.incr('incr other thing', console.log)
|
||||
|
||||
// runs immediately
|
||||
client.get('incr thing', console.log); // 100
|
||||
client.get('incr thing', console.log) // 100
|
||||
|
||||
// drains multi queue and runs atomically
|
||||
multi.exec(function (err, replies) {
|
||||
console.log(replies); // 101, 2
|
||||
});
|
||||
if (err) throw err
|
||||
console.log(replies) // 101, 2
|
||||
})
|
||||
|
||||
// you can re-run the same transaction if you like
|
||||
multi.exec(function (err, replies) {
|
||||
console.log(replies); // 102, 3
|
||||
client.quit();
|
||||
});
|
||||
if (err) throw err
|
||||
console.log(replies) // 102, 3
|
||||
client.quit()
|
||||
})
|
||||
|
Reference in New Issue
Block a user