I am using Redis npm library for Redis connection.
I am able to blpop from single queue like below
redis.blpop('firstQueue', timeOut, (err, reply) => {
console.log(reply);
});
But I want to pop from multiple queues like below
redis.blpop(['firstQueue', 'secondQueue', 'thrirdQueue'], timeOut, (err, reply) => {
console.log(reply);
});
But pop from multiple queue are not working.
I am using npm library Redis here
2
Answers
Here is a solution that works but beware I am not sure if this is efficient and if it’s good practice
(This question is old but just in case…)
If the package does not provide the function to
blpop
on several list at the same time (whereas redis allows this), you can directly try the sendCommand function:redis.sendCommand(command: string, cb?: Callback<any>): boolean;
with command string being something like
BLPOP firstQueue secondQueue thrirdQueue ${timeOut}
(see redis doc: https://redis.io/commands/blpop )