PUBSUB Returns Nothing
I'm trying to get the return value of the command PUBSUB NUMSUB "mychannel" by using the code:
client.pubsub(["NUMSUB", "mychannel"], function (err, res) {});
I have verified that the command is successfully parsed and sent to the Redis server, however I cannot figure out how to access the value it returns. The callback function is never called, and client.pubsub() always seems to simply return true.
Is there any way to access the return value? Since I am new to Node Redis, I can't tell if this is a bug or I'm just overlooking something.
This seems to be working fine for me:
c.pubsub(["NUMSUB", "foo"], function (err, reply) {
console.log("%s has %s subscribers", reply[0], reply[1])
})
// foo has 0 subscribers
You can also call it like client.pubsub("NUMSUB", "channel1", "channel2", callback)
Woops, I checked back at my code this morning, and it turns out it was just a race condition issue. I had the code client.end() a few lines afterward, which would end the client before it had the chance to call the callback.
Nevertheless, thanks for your help! :)