Redis Research (9)-ordered set type 2, redis research set type

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.