Redis 2.8源码 - redisObject

redisObject结构

对于 Redis的键值对来说,key一定是一个字符串(sds,也是一个redisObject)对象,而value则可以是五种对象的其中一种。

typedef struct redisObject {
    unsigned type:4;//对象的数据类型  4位
    unsigned encoding:4;//数据类型具体是哪种编码 4位
    unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */ //lru记录此对象最后一次访问的时间 24位 16 + 8 
    int refcount;//引用次数
    void *ptr;//真实指向的数据具体是
} robj;

type:
#define REDIS_STRING 0 字符串
#define REDIS_LIST 1  list 列表
#define REDIS_SET 2   set 集合
#define REDIS_ZSET 3  zset 有序集合
#define REDIS_HASH 4  hash 哈希

encoding 
#define REDIS_ENCODING_RAW 0     /* Raw representation */
#define REDIS_ENCODING_INT 1     /* Encoded as integer */
#define REDIS_ENCODING_HT 2      /* Encoded as hash table */
#define REDIS_ENCODING_ZIPMAP 3  /* Encoded as zipmap */
#define REDIS_ENCODING_LINKEDLIST 4 /* Encoded as regular linked list */
#define REDIS_ENCODING_ZIPLIST 5 /* Encoded as ziplist */
#define REDIS_ENCODING_INTSET 6  /* Encoded as intset */
#define REDIS_ENCODING_SKIPLIST 7  /* Encoded as skiplist */

借用网上找到的一张好图:
如图网上找到的一张好图

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值