-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratch.js
More file actions
42 lines (39 loc) · 963 Bytes
/
scratch.js
File metadata and controls
42 lines (39 loc) · 963 Bytes
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
36
37
38
39
40
41
42
var async = require('async')
, redis = require('redis')
, client = redis.createClient()
, tasks = [];
['boo','blah','bar','baz'].forEach(function (key, index) {
tasks.push(function (done) {
index = {
"test": "This is an object",
"nested": {
"nested_key": new Date()
},
"my_index": index
};
client.set("ROOT."+key, JSON.stringify(index), done);
});
});
async.parallel(tasks, function (err, replies) {
client.keys('ROOT*', function (err, reply) {
var tasks = [];
reply.forEach(function (key) {
tasks.push(function (done) {
client.get(key, function(err, reply) {
console.log(key +" = "+reply);
done(err, JSON.parse(reply));
});
});
});
tasks.push(function (done) {
client.get('blahblahblah', function (err, reply) {
console.log('blahblahblah = '+reply);
done(err, reply);
});
});
async.parallel(tasks, function (err, replies) {
console.log(replies);
process.exit(0);
});
});
});