I need to convert keys from type string to hash. The name of all keys is in the set list:of:keys
.
My current implementation looks like this:
var rdbc = require("redis").createClient(6379, '127.0.0.1');
rdbc.smembers("list:of:keys", function(err, strings){
strings.forEach(function(string, index, strings){
rdbc.get(string, function(err, result){
rdbc.del(string);
rdbc.hset(string, "foo", result);
});
});
});
My attempt works. But when list:of:keys
contains many values memory usage grows a lot.
Are there memory efficient structures to go through many keys? (especially
strings.forEach(…
seems inefficient)How do I inform the garbage collector in node.js to clean up after each
rdbc.del/rbdc.hset
operation?