Extracting various hashes from Redis in Node.js

How can I get various hashes from Redis to Node.js via node-redis ? The best way to get various hashes is through pipelines , but I have not found how to use them in Node.

+5
source share
1 answer

You can achieve this by using the command multifor the hash command queue:

var redis  = require("redis"),
    client = redis.createClient(),
    multi_queue;

multi_queue = client.multi();
...
for (key in keys) {
  multi_queue.hgetall(key);
}

multi_queue.exec(function (err, replies) {
  console.log("MULTI got " + replies.length + " replies");
  replies.forEach(function (reply, index) {
    console.log("Reply " + index + ": " + reply.toString());
  });
});
+9
source

All Articles