1
0
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:
Ruben Bridgewater
2017-05-06 07:06:52 +02:00
parent 5d29f541e9
commit f1a7bcd735
106 changed files with 10706 additions and 10978 deletions

View File

@@ -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()
})