(redis subscribe)
provides an utility of
Redis Pub/Sub. The basic idea is basically
a callback model.
To use this library, the following SRFIs must be supported by the impelementation:
- SRFI 1: List Library
- SRFI 13: String Libraries
- SRFI 18: Multithreading support
- SRFI 19: Time Data Types and Procedures
- SRFI 27: Sources of Random Bits
-
(redis-subscription? obj)
:Returns
#t
if the given obj is a Redis subscription. -
(redis-subscription-waiting? subscription)
:Returns
#t
if the given subscription is waiting for messages. -
(redis-subscribe! connection callback channel . channels)
:Creates a Redis subsctiption which uses callback as a callback procedure and subscribe to channel(s). Once the subscription is created, then the givne connection will be invalidated until all subscribed channels are unsubscribed.
-
(redis-subscribe! subscription channel . channels)
:Add given channel(s) to the subscription.
-
(redis-psubscribe! connection callback channel . channels)
:The same as
redis-subscribe!
but usesPSUBSCRIBE
command. -
(redis-psubscribe! subscription channel . channels)
:The same as
redis-subscribe!
but usesPSUBSCRIBE
command. -
(redis-unsubscribe! subscription . channels)
:Unsubscribe given channels from the subscription. If there's no channel is given, then it unsubscreibes all the subscription.
Once all the subscriptions are unsubscribed, then the connection of the subscription will be available again.
-
(redis-punsubscribe! subscription . channels)
:The same as
redis-unsubscribe!
but usingPUNSUBSCRIBE
.
The callback passed to either redis-subscribe!
or redis-psubscribe!
must accept 2 arguments, channel and body. The channel is a string
which is the name of the channel which receives the message. The body
is a bytevector which is the content of the received message.
If the callback throws an error, then entire backend thred will stops, so it is the users responsibility not to do so.