StackExchange.Redis: Get the count of channel subscriptions (i.e. PUBSUB NUMSUB)

白昼怎懂夜的黑 提交于 2019-12-23 17:55:24

问题


is there a way to get the number of channel subscriptions to a specific Redis channel through the StackExchange.Redis library? When interacting with Redis directly, it would work with the PUBSUB NUMSUB command (http://redis.io/commands/pubsub) but I don't see an equivalent call in the C# client library.


回答1:


This is a server command (as opposed to a database command), so the same guidance applies as for KEYS, SCAN, FLUSHDB, etc. Short version: use GetServer(). Longer version: read the linked article above.

The PUBSUB methods are:

  • PUBSUB CHANNELS: server.SubscriptionChannels[Async](...)
  • PUBSUB NUMPAT: server.SubscriptionPatternCount[Async](...)
  • PUBSUB NUMSUB: server.SubscriptionSubscriberCount[Async](...)


来源:https://stackoverflow.com/questions/26362640/stackexchange-redis-get-the-count-of-channel-subscriptions-i-e-pubsub-numsub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!