redis type

redis type define

/* The actual Redis Object */
#define OBJ_STRING 0    /* String object. */
#define OBJ_LIST 1      /* List object. */
#define OBJ_SET 2       /* Set object. */
#define OBJ_ZSET 3      /* Sorted set object. */
#define OBJ_HASH 4      /* Hash object. */

#define OBJ_MODULE 5    /* Module object. */
#define OBJ_STREAM 6    /* Stream object. */

 

OBJ_ENCODING

#define OBJ_ENCODING_RAW 0     /* Raw representation */
#define OBJ_ENCODING_INT 1     /* Encoded as integer */
#define OBJ_ENCODING_HT 2      /* Encoded as hash table */
#define OBJ_ENCODING_ZIPMAP 3  /* Encoded as zipmap */
#define OBJ_ENCODING_LINKEDLIST 4 /* No longer used: old list encoding. */
#define OBJ_ENCODING_ZIPLIST 5 /* Encoded as ziplist */
#define OBJ_ENCODING_INTSET 6  /* Encoded as intset */
#define OBJ_ENCODING_SKIPLIST 7  /* Encoded as skiplist */
#define OBJ_ENCODING_EMBSTR 8  /* Embedded sds string encoding */
#define OBJ_ENCODING_QUICKLIST 9 /* Encoded as linked list of ziplists */
#define OBJ_ENCODING_STREAM 10 /* Encoded as a radix tree of listpacks */

 

example

string

embstr

127.0.0.1:6379[2]> set name redisname
OK

127.0.0.1:6379[2]> type name
string

127.0.0.1:6379[2]> object encoding name
"embstr"

raw

127.0.0.1:6379[2]> set bigname abddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
OK
127.0.0.1:6379[2]> type bigname
string
127.0.0.1:6379[2]> object encoding bigname
"raw"

 

int

127.0.0.1:6379[2]> set viewcount 1000000
OK
127.0.0.1:6379[2]> type viewcount
string
127.0.0.1:6379[2]> object encoding viewcount
"int"



127.0.0.1:6379[2]> set bigcount 123456789123456
OK
127.0.0.1:6379[2]> type bigcount
string
127.0.0.1:6379[2]> object encoding bigcount
"int"

 

hash

127.0.0.1:6379[2]> hset map one 1 two 2
(integer) 2
127.0.0.1:6379[2]> type map
hash
127.0.0.1:6379[2]> object encoding map
"ziplist"

 

list

127.0.0.1:6379[2]> lpush mylist a b c
(integer) 3
127.0.0.1:6379[2]> type mylist
list
127.0.0.1:6379[2]> object encoding mylist
"quicklist"

set

127.0.0.1:6379[2]> sadd myset  ma mb mc
(integer) 3
127.0.0.1:6379[2]> type myset
set
127.0.0.1:6379[2]> object encoding myset
"hashtable"

 

sorted zset

127.0.0.1:6379[2]> zadd manager 11000 ma 22000 mb 31000 mc
(integer) 3
127.0.0.1:6379[2]> type manager
zset
127.0.0.1:6379[2]> object encoding manager
"ziplist"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/kq1983/article/details/114116852
Recommended