hiredis-vip库,集群,异步实例
下载地址:https://github.com/vipshop/hiredis-vip
hiredis-vip支持redis集群,异步操作,pipeline
异步操作需要libevent库支持
代码:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <hircluster.h>
#include <adapters/libevent.h>
const char *paddrs = "10.0.33.31:7000,10.0.33.31:7001,10.0.33.32:7000,10.0.33.32:7001,10.0.33.33:7000,10.0.33.33:7001";
redisClusterAsyncContext *predis_cluster_async_context = NULL;
struct event_base *base = NULL;
void redisAsyncCommandCallback(redisClusterAsyncContext *c, void *r, void *privdata)
{
redisReply *reply = (redisReply *)r;
if(NULL != reply)
{
printf("redisAsyncCommandCallback: %lld, %s\n", reply->integer, r