Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在Nodejs中,如何在多个队列上从redis弹出_Node.js_Redis - Fatal编程技术网

Node.js 在Nodejs中,如何在多个队列上从redis弹出

Node.js 在Nodejs中,如何在多个队列上从redis弹出,node.js,redis,Node.js,Redis,我正在使用Redis npm库进行Redis连接 我可以像下面这样从一个队列中跳出来 redis.blpop('firstQueue', timeOut, (err, reply) => { console.log(reply); }); redis.blpop(['firstQueue', 'secondQueue', 'thrirdQueue'], timeOut, (err, reply) => { console.log(reply)

我正在使用Redis npm库进行Redis连接

我可以像下面这样从一个队列中跳出来

redis.blpop('firstQueue', timeOut, (err, reply) => {
        console.log(reply);
});
redis.blpop(['firstQueue', 'secondQueue', 'thrirdQueue'], timeOut, (err, reply) => {
            console.log(reply);
 });
但我想从多个队列中弹出,如下所示

redis.blpop('firstQueue', timeOut, (err, reply) => {
        console.log(reply);
});
redis.blpop(['firstQueue', 'secondQueue', 'thrirdQueue'], timeOut, (err, reply) => {
            console.log(reply);
 });
但来自多个队列的pop不起作用


我正在使用npm库Redis,这里有一个可行的解决方案,但请注意,我不确定这是否有效,是否是一个良好的实践

client.batch().blpop('firstQueue', timeOut)
.blpop('secondQueue', timeOut)
.blpop('thrirdQueue', timeOut).exec(function(err, reply) {
  if (err) console.log(err)

  console.log(reply)
})