Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 575 Bytes

java.util.HashSet.adoc

File metadata and controls

28 lines (20 loc) · 575 Bytes

HashSet

Redis 中的 Set

Redis 中的集合对象编码可以是:

  1. intset

  2. hashtable

转换的条件是:

  1. 集合对象保存的所有元素都是整数值;

  2. 集合对象保存的元素个数不超过 512 个;(通过参数 set-max-intset-entries 来调整,默认是 512)

127.0.0.1:6379> SADD num 1 3 5
(integer) 3
127.0.0.1:6379> OBJECT encoding num
"intset"

127.0.0.1:6379> sadd num "seven"
(integer) 1
127.0.0.1:6379> OBJECT encoding num
"hashtable"

t_set.c/setTypeConvert 中执行转换操作。