redis-原理-对象-hash对象-hash(九)
hash对象底层的数据结构
hash对象的编码可以是ziplist(压缩列表)或者hashtable 注:3.2版本都是用quicklist
ziplist
127.0.0.1:0>hset profile name tom 1 127.0.0.1:0>hset profile age 25 1 127.0.0.1>hset profile career Programmer
数据结构
hashtable
127.0.0.1:0>hset profile name tom
1
127.0.0.1:0>hset profile age 25
1
127.0.0.1>hset profile career Programmer
数据结构
编码转换
1.键和值长度都小于64同时键值对个数要小于512使用ziplist否则使用hashtable
可以通过以下参数进行修改
hash-max-ziplist-value和hash-max-ziplist-entries
hset order:id:1 remark 333
这个时候使用的ziplist
后续我们
hset order:id:1 userName [超过512]
这个时候我们会由ziplist变成 hashtable
HASH命令