Redis--RedisObject结构

Redis中的每个对象都由一个redisObject结构表示,该结构中和保存数据有关的三个属性分别是type属性,encoding属性和ptr属性

 

typedef struct redisObject {

    // 类型
    unsigned type:4;

    // 编码
    unsigned encoding:4;

    // 对象最后一次被访问的时间
    unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */ int类型的一个数字

    // 引用计数
    int refcount;

    // 指向实际值的指针
    void *ptr;

} robj;

 

struct RedisObject { 
    int4 type;       // 4bit
    int4 encoding;   // 4bit
    int24 lru;       // 24bit
    int32 refcount;  // 4bytes
    void *ptr;       // 8bytes, 64-bit system
} robj;

  一共是16个字节

posted on 2021-01-08 11:42  MaXianZhe  阅读(90)  评论(0)    收藏  举报

导航