RedisX v0.9
A simple, light-weight Redis database client
|
Macros | |
#define | REDIS_SIMPLE_STRING_SIZE 256 |
(bytes) Only store up to this many characters from Redis confirms and errors. | |
#define | REDIS_TIMEOUT_SECONDS 3 |
(seconds) Abort with an error if cannot send before this timeout (<=0 for not timeout) | |
Functions | |
int | redisxAbortBlockAsync (RedisClient *cl) |
RESP * | redisxExecBlockAsync (RedisClient *cl) |
RedisClient * | redisxGetClient (Redis *redis, enum redisx_channel channel) |
RedisClient * | redisxGetLockedConnectedClient (Redis *redis, enum redisx_channel channel) |
int | redisxIgnoreReplyAsync (RedisClient *cl) |
int | redisxLockClient (RedisClient *cl) |
int | redisxLockConnected (RedisClient *cl) |
RESP * | redisxReadReplyAsync (RedisClient *cl) |
int | redisxResetClient (RedisClient *cl) |
int | redisxSendArrayRequestAsync (RedisClient *cl, char *args[], int lengths[], int n) |
int | redisxSendRequestAsync (RedisClient *cl, const char *command, const char *arg1, const char *arg2, const char *arg3) |
int | redisxSkipReplyAsync (RedisClient *cl) |
int | redisxStartBlockAsync (RedisClient *cl) |
int | redisxUnlockClient (RedisClient *cl) |
Basic I/O (send/receive) functions for the RedisX library.
int redisxAbortBlockAsync | ( | RedisClient * | cl | ) |
Abort an atomic transaction block. It sends DISCARD
.
cl | Pointer to a Redis client |
References redisxIgnoreReplyAsync(), TRUE, x_error(), X_NULL, and X_SUCCESS.
RESP * redisxExecBlockAsync | ( | RedisClient * | cl | ) |
Finish and execute an atomic transaction block. It sends EXEC
, skips through all OK
and QUEUED
acknowledgements, and returns the reply to the transaction block itself.
cl | Pointer to a Redis client |
References redisxDestroyRESP(), redisxReadReplyAsync(), redisxSkipReplyAsync(), RESP_ARRAY, RESP_ERROR, TRUE, RESP::type, x_error(), and x_trace_null().
RedisClient * redisxGetClient | ( | Redis * | redis, |
enum redisx_channel | channel | ||
) |
Returns the redis client for a given connection type in a Redis instance.
redis | Pointer to a Redis instance. |
channel | REDISX_INTERACTIVE_CHANNEL, REDISX_PIPELINE_CHANNEL, or REDISX_SUBSCRIPTION_CHANNEL |
References REDISX_CHANNELS, and x_error().
RedisClient * redisxGetLockedConnectedClient | ( | Redis * | redis, |
enum redisx_channel | channel | ||
) |
Returns the redis client for a given connection type in a Redis instance, with the exclusive access lock if the client is valid and is connected, or else NULL. It is effectively the combination of redisxGetClient()
followed by redisxLockConnected()
.
redis | Pointer to a Redis instance. |
channel | REDISX_INTERACTIVE_CHANNEL, REDISX_PIPELINE_CHANNEL, or REDISX_SUBSCRIPTION_CHANNEL |
References redisxGetClient(), redisxLockConnected(), X_SUCCESS, and x_trace_null().
int redisxIgnoreReplyAsync | ( | RedisClient * | cl | ) |
Silently consumes a reply from the specified Redis channel.
cl | Pointer to a Redis channel. |
References REDIS_NULL, redisxDestroyRESP(), redisxReadReplyAsync(), x_error(), X_NULL, X_SUCCESS, and x_trace().
int redisxLockClient | ( | RedisClient * | cl | ) |
int redisxLockConnected | ( | RedisClient * | cl | ) |
Lock a channel, but only if it has been enabled for communication.
cl | Pointer to the Redis client instance |
References redisxLockClient(), redisxUnlockClient(), x_error(), X_NO_SERVICE, and X_SUCCESS.
RESP * redisxReadReplyAsync | ( | RedisClient * | cl | ) |
Reads a response from Redis and returns it.
cl | Pointer to a Redis channel |
References FALSE, RESP::n, REDIS_INCOMPLETE_TRANSFER, REDIS_SIMPLE_STRING_SIZE, REDIS_UNEXPECTED_RESP, redisxDestroyRESP(), redisxReadReplyAsync(), RESP_ARRAY, RESP_BULK_STRING, RESP_ERROR, RESP_INT, RESP_SIMPLE_STRING, RESP::type, RESP::value, x_error(), X_FAILURE, X_PARSE_ERROR, X_SUCCESS, x_trace_null(), and xStringCopyOf().
int redisxResetClient | ( | RedisClient * | cl | ) |
Sends a RESET
request to the specified Redis client. The server will perform a reset as if the client disconnected and reconnected again.
cl | The Redis client |
References REDIS_UNEXPECTED_RESP, redisxCheckRESP(), redisxDestroyRESP(), redisxLockConnected(), redisxReadReplyAsync(), redisxSendRequestAsync(), redisxUnlockClient(), RESP_SIMPLE_STRING, RESP::value, x_error(), X_NULL, and X_SUCCESS.
int redisxSendArrayRequestAsync | ( | RedisClient * | cl, |
char * | args[], | ||
int | lengths[], | ||
int | n | ||
) |
Send a Redis request with an arbitrary number of arguments.
cl | Pointer to the Redis client. |
args | The array of string arguments to send. |
lengths | Array indicating the number of bytes to send from each string argument. Zero or negative values can be used to determine the string length automatically using strlen(), and the length argument itself may be NULL to determine the lengths of all string arguments automatically. |
n | The number of arguments to send. |
References FALSE, REDISX_CMDBUF_SIZE, TRUE, x_error(), X_NULL, and X_SUCCESS.
int redisxSendRequestAsync | ( | RedisClient * | cl, |
const char * | command, | ||
const char * | arg1, | ||
const char * | arg2, | ||
const char * | arg3 | ||
) |
Send a command (with up to 3 arguments) to the Redis server. The caller must have an exclusive lock on the client for this version. The arguments supplied will be used up to the first non-NULL value.
cl | Pointer to the Redis client instance. |
command | Redis command string. |
arg1 | Optional first string argument or NULL. |
arg2 | Optional second string argument or NULL. |
arg3 | Optional third string argument or NULL. |
References redisxSendArrayRequestAsync(), x_error(), X_NAME_INVALID, X_NULL, and X_SUCCESS.
int redisxSkipReplyAsync | ( | RedisClient * | cl | ) |
Instructs Redis to skip sending a reply for the next command.
Sends CLIENT REPLY SKIP
cl | Pointer to the Redis client to use. |
int redisxStartBlockAsync | ( | RedisClient * | cl | ) |
Starts an atomic Redis transaction block, by sending MULTI
on the specified client connection. Redis transaction blocks behave just like scripts (in fact they are effectively improptu scripts themselves). As such the rules of Redis scripting apply, such as you cannot call LUA from within a transaction block (which is a real pity...)
Once you start a transaction block you may ignore all acknowledgedments such as OK
and QUEUED
responses that Redis sends back. These will be 'processed' in bulk by redisEndBlockAsync(), at the end of the transaction block.
cl | Pointer to a Redis client. |
int redisxUnlockClient | ( | RedisClient * | cl | ) |