client.get("a", function (err, reply) { var a = reply.toString(); console.log(a); });client.get("b", function (err, reply) { var b = reply.toString(); console.log(b); });
nodejs异步 redis分别获取a,b 这样可以实现 但我不想异步回调两个函数 我想同时获取a b并且同时输出
解决方案
你想要的是这个吧,使用mget
:
client.mget(['sessions started', 'sessions started', 'foo'], function (err, res) { console.dir(res);});