首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >关于 redisCommand 以及 redisReply

关于 redisCommand 以及 redisReply

作者头像
看、未来
发布2021-12-23 15:17:03
发布2021-12-23 15:17:03
1.2K0
举报

源码不长,五分钟就都能翻出来。

代码语言:javascript
复制
void* redisCommand(redisContext c,const char format,...); 

返回值是一个void类型的指针,实际为指向一个redisReply类型的指针

redisReply结构体定义如下:

代码语言:javascript
复制
/* This is the reply object returned by redisCommand() */
typedef struct redisReply {
    int type; /* REDIS_REPLY_* */
    long long integer; /* The integer when type is REDIS_REPLY_INTEGER */
    size_t 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 */
} redisReply;

下面是几种redis的常见错误及返回值类型:

代码语言:javascript
复制
#define REDIS_ERR -1
#define REDIS_OK 0
 
//错误码
#define REDIS_ERR_IO 1 /* Error in read or write */
#define REDIS_ERR_EOF 3 /* End of file */
#define REDIS_ERR_PROTOCOL 4 /* Protocol error */
#define REDIS_ERR_OOM 5 /* Out of memory */
#define REDIS_ERR_OTHER 2 /* Everything else... */
 
//OK码
#define REDIS_REPLY_STRING 1    //存放在char *str
#define REDIS_REPLY_ARRAY 2		 //存储数组
#define REDIS_REPLY_INTEGER 3   //integer存储为数据条数
#define REDIS_REPLY_NIL 4			 // null值
#define REDIS_REPLY_STATUS 5   //成功状态码为:"OK"  存放在char *str
#define REDIS_REPLY_ERROR 6    //存放在char *str
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/12/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档