RedisObject详解
[toc]
Redis中任意数据类型的键和值都会被封装成一个RedisObject,也叫作Redis对象,结构如下
1 2 3 4 5 6 7 8
| struct redisObject { unsigned type:4; unsigned encoding:4; unsigned lru:LRU_BITS; int refcount; void *ptr; };
|
type:
1 2 3 4 5 6
| #define OBJ_STRING 0 #define OBJ_LIST 1 #define OBJ_SET 2 #define OBJ_ZSET 3 #define OBJ_HASH 4
|
Encoding:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| #define OBJ_ENCODING_RAW 0 #define OBJ_ENCODING_INT 1 #define OBJ_ENCODING_HT 2 #define OBJ_ENCODING_ZIPMAP 3 #define OBJ_ENCODING_LINKEDLIST 4 #define OBJ_ENCODING_ZIPLIST 5 #define OBJ_ENCODING_INTSET 6 #define OBJ_ENCODING_SKIPLIST 7 #define OBJ_ENCODING_EMBSTR 8 #define OBJ_ENCODING_QUICKLIST 9 #define OBJ_ENCODING_STREAM 10 #define OBJ_ENCODING_LISTPACK 11 #define OBJ_ENCODING_LISTPACK_EX 12
|