|
int | redisxAddSubscriber (Redis *redis, const char *channelStem, RedisSubscriberCall f) |
|
int | redisxClearSubscribers (Redis *redis) |
|
int | redisxEndSubscription (Redis *redis) |
|
int | redisxNotify (Redis *redis, const char *channel, const char *message) |
|
int | redisxPublish (Redis *redis, const char *channel, const char *data, int length) |
|
int | redisxPublishAsync (Redis *redis, const char *channel, const char *data, int length) |
|
int | redisxRemoveSubscribers (Redis *redis, RedisSubscriberCall f) |
|
int | redisxSubscribe (Redis *redis, const char *pattern) |
|
int | redisxUnsubscribe (Redis *redis, const char *pattern) |
|
- Date
- Created on Aug 26, 2024
- Author
- Attila Kovacs
PUB/SUB functions for the RedisX library.
Add a targeted subscriber processing function to the list of functions that process Redis PUB/SUB responses. You will still have to subscribe the relevant PUB/SUB messages from redis separately, using redisxSubscribe() before any messages are delivered to this client. If the subscriber with the same callback function and channel stem is already added, this call simply return and will NOT create a duplicate enry. However, the same callback may be added multiple times with different channel stems (which pre-filter what messages each of the callbacks may get).
- Parameters
-
redis | Pointer to a Redis instance. |
channelStem | If NULL, the consumer will receive all Redis messages published to the given channel. Otherwise, the consumer will be notified only if the incoming channel begins with the specified stem. |
f | A function that consumes subscription messages. |
- See also
- redisxRemoveSubscribers()
-
redisxSubscribe()
References x_error(), X_NULL, X_SUCCESS, x_warn(), xStringCopyOf(), and xvprintf.
int redisxPublish |
( |
Redis * |
redis, |
|
|
const char * |
channel, |
|
|
const char * |
data, |
|
|
int |
length |
|
) |
| |
Sends a generic Redis PUB/SUB message on the specified channel. Redis must be connected before attempting to send messages. It will send the message over the pipeline client if it is avaiable, or else over the interactive client.
- Parameters
-
redis | Pointer to a Redis instance. |
channel | Redis PUB/SUB channel on which to notify |
data | Data to send. |
length | Bytes of data to send, or 0 to determine automatically with strlen(). |
- Returns
- X_SUCCESS if the message was successfullt sent. X_NO_INIT if the Redis library was not initialized via initRedis(). X_NO_SERVICE if there was a connection problem. PARSE_ERROR if the Redis response could not be confirmed.
- See also
- redisxNotify()
-
redisxPublishAsync()
-
redisxSubscribe()
References Redis::id, Redis::interactive, redisxLockConnected(), redisxPublishAsync(), redisxUnlockClient(), x_error(), X_NULL, X_SUCCESS, and xvprintf.
int redisxUnsubscribe |
( |
Redis * |
redis, |
|
|
const char * |
pattern |
|
) |
| |
Unsubscribe from one or all Redis PUB/SUB channel(s). If there are no active subscriptions when Redis confirms the unsubscrive command, the subscription listener thread will also conclude automatically. Unsubscribing will stop delivery of mesasages for the affected channels but any associated processing callbacks remain registered, until redisxRemovesubscribers() is called to deactive them as appropriate.
- Parameters
-
redis | Pointer to a Redis instance. |
pattern | The channel pattern, or NULL to unsubscribe all channels and patterns. |
- Returns
- X_SUCCESS if successfully subscribed to the Redis distribution channel. X_NO_SERVICE if there is no active connection to the Redis server.
- See also
- redisxSubscribe()
-
redisxEndSubscribe()
-
redisxRemoveSubscribers()
References redisxLockConnected(), redisxSendRequestAsync(), redisxUnlockClient(), Redis::subscription, x_error(), X_NULL, and X_SUCCESS.