Create: (The concept of a weight exists in an ordered set)
Zadd Zset 1 a 2 B 3 C 4 D 5 e 6 F 7 G# output:# 1) "A"# 2) "B" c7># 3) "C"# 4) "D"# 5) "E"# 6) "F" # 7) "G"# left weight, right element
View:
Zrange zset 0-1 # index value, first and last
Reverse View:
Zrevrange zet 0-1# output:# 1) "G"# 2) "F"# 3) "E" c8># 4) "D"# 5) "C"# 6) "B"# 7) "a"
Delete:
Zrem Zset g (Element)
Element value view to view the corresponding index value:
Zrank Zset a # 0 (index value)
Flashback view element value relative to index value;
Zrevrank Zset a # 6 (' G ' has been removed before)
Number of Views:
Zcard zset # 6
View weights:
# 1 (weight)zscore zset F # 6 (weight)
Returns the elements of an ordered set of score (weights) at a given interval:
Zrangebyscore Zset 3 5 withscores # view elements with weights between 3 and 5 (closed interval)# output:
1) "C"
2) "3"
3) "D"
4) "4"
5) "E"
6) "5"
Returns the number of score (weights) in a given interval in an ordered set:
# the number of elements with weights between 3 and 5 # Output: 3
Delete an indexed value in an ordered set of elements in a given interval:
Zremrangebyrank Zset 3 5 # Delete an element with an index value from 3 to 5 (closed interval)# return number 3 means D E F has been removed #< /c10> 's got a B-C left .
Delete the elements of a given interval in an ordered set of weights:
Zremrangebyscore zset 1 3 # Remove weights from 1 to 3 (closed interval)# Returns the number 3 means a B c has been deleted # now ordered set Zset is empty
Redis database Operations--zset ordered collection under LUnix