-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis.js
35 lines (32 loc) · 939 Bytes
/
redis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
console.log("surya");
var redis = require('redis'), set_size = 10;
var client = redis.createClient();
//client.auth('foobared', function (err) {
// if (err) throw err;
//});
client.on('connect', function() {
console.log('Connected to Redis');
});
client.get("rest_discount", function (err, reply) {
if (err) throw err;
console.log("rest_discount = " + reply.toString());
});
/*
client.sadd("bigset", "a member");
client.sadd("bigset", "another member");
while (set_size > 0) {
client.sadd("bigset", "member " + set_size);
set_size -= 1;
}
*/
// multi chain with an individual callback
client.multi()
.scard("bigset")
.smembers("bigset")
.dbsize()
.exec(function (err, replies) {
console.log("MULTI got " + replies.length + " replies");
replies.forEach(function (reply, index) {
console.log("Reply " + index + ": " + reply.toString());});
client.quit();
});