Redis command to list all subscribers subscribed to redis channel

Below command only gives channel list .

127.0.0.1:6379> PUBSUB CHANNELS
1) "mychannel"
2) "mychanne2"

How to LIST subscribers subscribed on channel1 OR channel2 .?

also

i din't found redis command to list all subscribers Of a particular channel

Answers:

Answer

I can achieve this with something like:

redis_client.multi().client(['list']).exec(function(err, results) {
  var pairs = results[0].split(' ');
  pairs.forEach(function(pair){
    var kv = pair.split('=');
    if (kv[0] == 'name' && kv[1] == constants.REDIS_SUBSCRIBER_NAME)
      found = true;
  });
  if (found) // some logic
  else // some logic
});
Answer

You can use PUBSUB NUMSUB channel1 OR PUBSUB NUMSUB channel2 and get reply about the number of subscribers for the specified channel.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.