Class | EventMachine::Hiredis::PubsubClient |
In: |
lib/em-hiredis/pubsub_client.rb
|
Parent: | BaseClient |
PUBSUB_MESSAGES | = | %w{message pmessage subscribe unsubscribe psubscribe punsubscribe}.freeze |
PING_CHANNEL | = | '__em-hiredis-ping' |
Pubsub connections to not support even the PING command, but it is useful, especially with read-only connections like pubsub, to be able to check that the TCP connection is still usefully alive.
This is not particularly elegant, but it‘s probably the best we can do for now. Ping support for pubsub connections is being considerred: github.com/antirez/redis/issues/420
Pattern subscribe to a pubsub channel
If an optional proc / block is provided then it will be called (with the channel name and message) when a message is received on a matching channel
@return [Deferrable] Redis psubscribe call
Pattern unsubscribe all callbacks for a given pattern
@return [Deferrable] Redis punsubscribe call
Unsubscribe a given callback from a pattern. Will unsubscribe from redis if there are no remaining subscriptions on this pattern
@return [Deferrable] Succeeds when the punsubscribe has completed or
fails if callback could not be found. Note that success may happen immediately in the case that there are other callbacks for the same pattern (and therefore no punsubscription from redis is necessary)
Subscribe to a pubsub channel
If an optional proc / block is provided then it will be called when a message is received on this channel
@return [Deferrable] Redis subscribe call
Unsubscribe all callbacks for a given channel
@return [Deferrable] Redis unsubscribe call
Unsubscribe a given callback from a channel. Will unsubscribe from redis if there are no remaining subscriptions on this channel
@return [Deferrable] Succeeds when the unsubscribe has completed or
fails if callback could not be found. Note that success may happen immediately in the case that there are other callbacks for the same channel (and therefore no unsubscription from redis is necessary)