That's not how you use multi
/exec
. The multi
call returns an object that you must hold on to:
client = redis.createClient(REDIS_SOCK);
client.keys(['*'], function(err, keys) {
multi = client.multi();
keys.forEach(function(key) {
count = start;
while(count <= end) {
multi.zrangebyscore([key, count, count + 120000], function() {});
count += 120000;
}
});
multi.exec(function(err, results) {
if(err) { console.log(err); }
else { console.log(results); }
client.quit();
});
});
Since you can have many multi
s active at a time, this is how the redis lib knows which one you're trying to exec.