bnoguchi/redis-node

how to perform multi queries?

Closed this issue · 3 comments

I've looked through the source, tests and example but I'm at a loss. How do you do multi queries with redis-node?

A longer tutorial such as http://www.paperplanes.de/2010/11/29/a_simple_redis_use_case.html would be really nice, for example the multi call I'm trying to replicate in node looks like this in ruby:

members = redis.sort('instance_startup_time')
redis.multi do
  members.each do |member|
    redis.zscore('instance_startup_time', member)
  end
end

You do this via the client's transaction method. I just pushed a newer README that has an example of how to MULTI/EXEC with this method.

In your case:

client.sort('instance_startup_time', {order: 'asc'}, function (err, members) {
    client.transaction( function () {
        members.forEach( function (member) {
            client.zscore('instance_startup_time, member, function (err, score) {
                console.log(score);
            });
        });
    });
});

--Brian

Closed.

Great - thanks for the guidance!