同步调用
连接
redisContext* redisConnect(constchar*ip,intport);
发送命令并且获取响应
void *redisCommand(redisContext *c, const char *format, ...);
返回的结果结构体为
typedef struct redisReply {int type; /* REDIS_REPLY_* */long long integer; /* The integer when type is REDIS_REPLY_INTEGER */int len; /* Length of string */char *str; /* Used for both REDIS_REPLY_ERROR and REDIS_REPLY_STRING */size_t elements; /* number of elements, for REDIS_REPLY_ARRAY */struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */
} redisRepl
type支持的值有
- REDIS_REPLY_STRING
- REDIS_REPLY_ARRAY
- REDIS_REPLY_INTEGER
- REDIS_REPLY_NIL
- REDIS_REPLY_STATUS
- REDIS_REPLY_ERROR
释放响应对象
void freeReplyObject(void *reply)