aboutsummaryrefslogtreecommitdiffstats
path: root/signaling-server/node_modules/socket.io/node_modules/redis/examples/subquery.js
blob: 861657e1f3a2cb85690f90cda371fe462d1bc4ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var client = require("redis").createClient();

function print_results(obj) {
    console.dir(obj);
}

// build a map of all keys and their types
client.keys("*", function (err, all_keys) {
    var key_types = {};
    
    all_keys.forEach(function (key, pos) { // use second arg of forEach to get pos
        client.type(key, function (err, type) {
            key_types[key] = type;
            if (pos === all_keys.length - 1) { // callbacks all run in order
                print_results(key_types);
            }
        });
    });
});