Skip to content
deep edited this page May 23, 2017 · 19 revisions

CLUSTER SUPPORT

FEATURES:

  • SUPPORT REDIS CLUSTER:

    • Connect to redis cluster and run commands. Handled ask and moved redirection.
  • SUPPORT MULTI-KEY COMMAND:

    • Support MSET, MGET and DEL.
  • SUPPORT PIPELINE:

    • Support redis pipeline and can contain multi-key command like above.
  • SUPPORT Asynchronous API:

    • User can run commands with asynchronous mode.

CLUSTER API

connect to redis cluster

redisClusterContext *redisClusterConnect(const char *addrs, int flags);

Connect to redis cluster and set a timeout

redisClusterContext *redisClusterConnectWithTimeout(const char *addrs, const struct timeval tv, int flags);

Connect to redis cluster with nonblock mode

redisClusterContext *redisClusterConnectNonBlock(const char *addrs, int flags);

Release the redisClusterContext

void redisClusterFree(redisClusterContext *cc);

Set the MaxRedirect

void redisClusterSetMaxRedirect(redisClusterContext *cc, int max_redirect_count);

Execute the command and get the reply

void *redisClusterCommand(redisClusterContext *cc, const char *format, ...);

Append the command for pipeline

int redisClusterAppendCommand(redisClusterContext *cc, const char *format, ...);

Get the reply for pipeline

int redisClusterGetReply(redisClusterContext *cc, void **reply);

If you do not care about the reply for pipeline, then do not use redisClusterGetReply() , just calls redisCLusterReset one time. If the reply in the redisClusterGetReply() returns error, in the end calls redisCLusterReset one time.

void redisCLusterReset(redisClusterContext *cc);

Connect to redis cluster for asynch

redisClusterAsyncContext *redisClusterAsyncConnect(const char *addrs, int flags);

Set the connection callback for asynch

int redisClusterAsyncSetConnectCallback(redisClusterAsyncContext *acc, redisConnectCallback *fn);

Set the disconnection callback for asynch

int redisClusterAsyncSetDisconnectCallback(redisClusterAsyncContext *acc, redisDisconnectCallback *fn);

Execute the commands for asynch

int redisClusterAsyncCommand(redisClusterAsyncContext *acc, redisClusterCallbackFn *fn, void *privdata, const char *format, ...);

Disconnect to redis cluster and release the resource

void redisClusterAsyncDisconnect(redisClusterAsyncContext *acc);

Release the resource

void redisClusterAsyncFree(redisClusterAsyncContext *acc);

EXAMPLES