Unordered Collection Sadd
The set set is directly de-Xiao and only outputs the hehe
Sadd names3 Xiao Xiao hehe hehe
Gets all the values of the collection Names3, and the collection cannot get the value as a slice because it is unordered
Smembers Names3
Gets the number of elements in the NAMES3 corresponding collection
SCard Names3
Difference set of two sets:
Sdiff Names3 Names4
The difference set of two sets and the resulting results are assigned to the new set N6:
Sdiffstore N6 names3 Names4
Intersection:
SINTER Names3 Names4
Determine if there are hehe elements inside the NAMES3:
Sismember Names3 hehe
Move from one collection to another:
Smove (SRC, DST, value)
# 将某个成员从一个集合中移动到另外一个集合
Randomly gets the elements inside a collection:
Srandmember Names3
#从name对应的集合中随机获取 numbers 个元素
Srandmember
#在name对应的集合中删除某些值
Srem Names3 hehe
and set:
Sunion Names3 Names4
# 获取多一个name对应的集合的并集,并将结果保存到dest对应的集合中
Sunionstore (Dest,keys, *args)
Sets the names3,names4 result of the collection, which is stored in the collection N7, and then viewed with Sscan
Ordered collection: Zadd
To add a collection z1:
Zadd Z1 Xiaopang 5 jack 8 rain 4 Jane #可以改数字, value cannot be changed
Gets the value of the collection Z1 (ordered by range)
Zrange Z1 0-1 withscores (show numbers)
The element fraction range in the collection:
Zcount Z1 4 10 (4 10 is min max)
# 自增name对应的有序集合的 name 对应的分数
Zincrby (name, value, amount)
# 获取某个值在 name对应的有序集合中的排行(从 0 开始)
Zrank Z1 Xiaopang
# 根据排行范围删除
Zremrangebyrank (name, Min, max)
Get the score based on the name value:
Zscore Z1 Xiaopang
Two sets of intersections, and assigns a value to the new collection:
Zinterstore Z3 2 Z1 Z2 #2是代表有两个集合的交集
Delete key and set the time-out:
Expire (name, time)
Python-redis Collection Mode