Redis Research (9)-ordered set type 2, redis research set type
The previous article has talked about some commands of the ordered set type.
Http://blog.csdn.net/wtyvhreal/article/details/42804571
Iii. Command collection
1. Get the number of elements in the Set
zcard key
2. Obtain the number of elements in the specified score range.
<span style="font-size:14px;">zcount key min max</span>
3. delete one or more elements
<span style="font-size:14px;">zrem key member</span>
The returned value is the number of successfully deleted elements (excluding elements that do not exist)
4. Delete elements by ranking range
zremrangebyrank key start stop
Delete all elements in the specified ranking according to the order of scores (starting from 0) and return the number of deleted elements.
5. Delete elements by score range
zremrangebyscore key min max
The returned value is the number of deleted elements.
E with the score of 5 is deleted, and d and f are left.
6. Obtain the ranking of Elements
zrank key memberzrevrank key member
Obtain the rank of the specified Element in the ascending order of the element score (starting from 0 ).
7. Calculate the intersection of Ordered Sets
It is used to calculate the intersection of multiple Ordered Sets and store the results in the destination key (also stored as an ordered set type). The returned value is the number of elements in the destination key.
The score of the element in the destination key is determined by the AGGREGATE parameter.
(1) When AGGREGATE is SUM (default), the element score in the destination key is the SUM of the scores of this element in each set involved in calculation.
(2) When AGGREGATE is MIN, the element score in the destination key is the minimum value of the element score of each set involved in calculation.
(3) When AGGREGATE is MAX, the element score in the destination key is the maximum value of this element score in each set involved in calculation.
The ZINTERSTORE command sets the WEIGHTS of each set through the WEIGHTS parameter. When each set is involved in calculation, the scores of the elements are multiplied by the WEIGHTS of the set.
2 = 1 + 10*0.1
4 = 2 + 20*0.1
Another imperative ZUNIONSTORE is used to calculate the union between sets.