最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Redis command to list all subscribers subscribed to redis channel - Stack Overflow

programmeradmin2浏览0评论

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

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

Share Improve this question edited Feb 11, 2016 at 20:24 Jonatas Walker 14.2k6 gold badges56 silver badges82 bronze badges asked Feb 11, 2016 at 17:14 Mr punchMr punch 1,9064 gold badges18 silver badges23 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 10

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

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
});
发布评论

评论列表(0)

  1. 暂无评论