I search through redis command list. I couldn't find the command to get all the available channels in redis pub/sub. In meteor server, the equivalent command is LISTCHANNELS
, where it lists all known channels, the number of messages stored on each one and the number of current subscribers.
I have a cron that needs to periodically know about the available channels. Does redis have native command for this? Or I need to find a way to implement it myself?
Aside from data storage, Redis can be used as a Publisher/Subscriber platform. In this pattern, publishers can issue messages to any number of subscribers on a channel. These messages are fire-and-forget, in that if a message is published and no subscribers exists, the message evaporates and cannot be recovered.
Redis Pub/Sub implements the messaging system where the senders (in redis terminology called publishers) sends the messages while the receivers (subscribers) receive them. The link by which the messages are transferred is called channel. In Redis, a client can subscribe any number of channels.
You can use PUBSUB NUMSUB channel1 OR PUBSUB NUMSUB channel2 and get reply about the number of subscribers for the specified channel.
To list the keys in the Redis data store, use the KEYS command followed by a specific pattern. Redis will search the keys for all the keys matching the specified pattern. In our example, we can use an asterisk (*) to match all the keys in the data store to get all the keys.
PUBSUB CHANNELS
does this as of version 2.8.0.
There is no existing command - look at http://redis.io/commands#pubsub. You can save all channels' names in SET
and retrieve them, when it is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With