RedisX v0.9
A simple, light-weight Redis database client
Loading...
Searching...
No Matches
redisx-hooks.c File Reference

Functions

int redisxAddConnectHook (Redis *redis, void(*setupCall)(Redis *))
 
int redisxAddDisconnectHook (Redis *redis, void(*cleanupCall)(Redis *))
 
void redisxClearConnectHooks (Redis *redis)
 
void redisxClearDisconnectHooks (Redis *redis)
 
int redisxRemoveConnectHook (Redis *redis, void(*setupCall)(Redis *))
 
int redisxRemoveDisconnectHook (Redis *redis, void(*cleanupCall)(Redis *))
 

Detailed Description

Date
Created on Aug 26, 2024
Author
Attila Kovacs

A set of functions to manage callback hooks for the RedisX library.

Function Documentation

◆ redisxAddConnectHook()

int redisxAddConnectHook ( Redis redis,
void(*)(Redis *)  setupCall 
)

Adds a connect call hook, provided it is not already part of the setup routine.

Parameters
redisPointer to a Redis instance.
setupCallUser-specified callback routine to be called after the Redis instance has been connected. It will be passed a pointer to the Redis instance, which triggered the call by having established connection.
Returns
X_SUCCESS (0) if successful or else X_NULL if either of the arguments is NULL.

References x_error(), X_NULL, X_SUCCESS, and xvprintf.

◆ redisxAddDisconnectHook()

int redisxAddDisconnectHook ( Redis redis,
void(*)(Redis *)  cleanupCall 
)

Adds a cleanup call, provided it is not already part of the cleanup routine, for when the specified Redis instance is disconnected.

Parameters
redisPointer to a Redis instance.
cleanupCallUser specified function to call when Redis is disconnected. It will be passed a pointer to the Redis instance, which triggered the call by having disconnected from the Redis server.
Returns
X_SUCCESS (0) if successful or else X_NULL if either of the arguments is NULL.

References x_error(), X_NULL, X_SUCCESS, and xvprintf.

◆ redisxClearConnectHooks()

void redisxClearConnectHooks ( Redis redis)

Removes all connect hooks, that is no user callbacks will be made when the specifed Redis instance is connected.

Parameters
redisPointer to a Redis instance.

References xvprintf.

◆ redisxClearDisconnectHooks()

void redisxClearDisconnectHooks ( Redis redis)

Removes all disconnect hooks, that is no user-specified callbacks will be made when the specified Redis instance is disconnected.

Parameters
redisPointer to a Redis instance.

References xvprintf.

◆ redisxRemoveConnectHook()

int redisxRemoveConnectHook ( Redis redis,
void(*)(Redis *)  setupCall 
)

Removes a connect call hook.

Parameters
redisPointer to a Redis instance.
setupCallUser-specified callback routine to be called after the Redis instance has been connected.
Returns
X_SUCCESS (0) if successful or else X_NULL if either of the arguments is NULL.

References x_error(), X_NULL, X_SUCCESS, and xvprintf.

◆ redisxRemoveDisconnectHook()

int redisxRemoveDisconnectHook ( Redis redis,
void(*)(Redis *)  cleanupCall 
)

Removes a cleanup call hook for when the Redis instance is disconnected.

Parameters
redisPointer to a Redis instance.
cleanupCallUser specified function to call when Redis is disconnected.
Returns
X_SUCCESS (0) if successful or else X_NULL if the argument is NULL.

References x_error(), X_NULL, X_SUCCESS, and xvprintf.