Skip to content

Instantly share code, notes, and snippets.

@atree
Created January 17, 2013 16:30
Show Gist options
  • Save atree/4557289 to your computer and use it in GitHub Desktop.
Save atree/4557289 to your computer and use it in GitHub Desktop.
Node JS - Iterating over redis keys, grabbing value from hash for view.
exports.list = function(req, res) {
var return_dataset = [];
client.keys('*', function(err, log_list) {
var multi = client.multi();
var keys = Object.keys(log_list);
var i = 0;
keys.forEach(function (l) {
client.hget(log_list[l], "modified_at", function(e, o) {
i++;
if (e) {console.log(e)} else {
temp_data = {'key':log_list[l], 'modified_at':o};
return_dataset.push(temp_data);
}
if (i == keys.length) {
res.render('logger/list', {logs:return_dataset});
}
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment