Redis 4: an ordered set of Storage types

Source: Internet
Author: User
Tags sorts
An ordered set seems to be a bigger operation because a thing called "molecule" is actually like a common data. It just adds a pure digital identifier to the data, use these identifiers to obtain the desired data! The numerator can be an integer or a dual-precision floating point: ========================================================== ============== 1. zadd num 100 A 80 B 70 C add an ordered set named num, element a is 100 points, Element B is 80 points .... 2. zscore num A obtains the numerator with the element name a in the num set ======================== ======================================= 3. zrange num 0 2 returns the num set from 0 index to 2 Index! Return c B a4.zrange num 0 2 withscores in ascending order, which is the same as above, but will output the molecules simultaneously C 70 B 80 A 1005. zrevrange is used in the same way as the above two, the difference is that the sorting is from large to small ========================================== =============================== 6. zrangebyscore num 80 100 returns all elements between 80 and 100. zrangebysocrenum (80 100 returns all elements between the 81-100 Numerator. Adding half a bracket does not include the current endpoint 8. the above two commands can be added with withscores, display the numerator and element at the same time ==================================== ================================= 9. zrangebysocrenum 60 200 limit 0 2 get the first two molecules between 60 and 200 in the num set (index 0 starts, take 2) ========================================================== ================= 10. zincrby num 4 A (negative number can be used to reduce the score) to + 411 for the numerator named a in the num set. zcard num obtains 12 elements in the num set. zcount num 80 200 get the total number of elements between 80 and 200 in the num set. 13. zrem num A deletes a14.zremrangebyrank num 0 2 deletes three elements (including the deletion of molecules) from index 0 to index 2 in the num set. zremrangebysocrenum 40 200 delete all elements (including the deleted elements) between 40 and 200 in the num set. 16. zrank num a returns zrevrank num A, which sorts the elements in num in descending order of molecules. zrevrank num a sorts the elements from largest to smallest. zinterstore num5 2 num2 num adds the numerator of the corresponding element in num2 and num, save the result to num5 and zadd num1 1 A 2 B 3 C zadd num2 10 C 20 A 30 B zinterstore num3 2 num1 num2 zrange num3 0-1 withscores returns: C 23 B 32 A 2118. zinterstore num5 2 num2 num aggregate Min is the same as above, but only the minimum value is required to participate in the return: C 3 B 2 A 119. zinterstore num5 2 num2 num aggregate Max maximum value involved
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.