Redis data type operation (v)--sorted Set

Source: Internet
Author: User
Tags sorts

1. Zadd

Format: Zadd ' name ' {num} ' value '

Add value to the sorted set named name. Num is the ordinal value of the element, and if the added num already exists, it does not overwrite the original value, and there will be two different values for the same num. However, a new num value can be given to a value that already exists.


2. Zrange

Format: Zrange ' name ' {NUM1} {num2} [Withscores]

Get the element named name of sorted set inside {NUM1} to {num2} subscript. The withscores will output the sequence number.


3. Zrangebyscore

Format: Zrangebyscore ' name ' {NUM1} {num2} [Withscores]

Get the element named name of the sorted set inside {NUM1} to {num2} sequence number (not subscript). The withscores will output the sequence number.


4. Zrem

Format: Zrem ' name ' ' value '

The value is removed from the sorted set named name.


5. Zincrby

Format: zincrby±{num} ' name ' ' value '

Let the order number of value increment by num, and if value does not exist, add value to sorted set with NUM for the order number. If NUM is negative, it is reduced.


6. Zrank

Format: Zrank ' name ' ' value '

Sorts the sorted set named name first in ascending order, and then returns the subscript for the sorted value.


7. Zrevrank

Format: Zrevrank ' name ' ' value '

Sorts the sorted set named name first in descending order, and then returns the subscript for the sorted value.


8. Zcount

Format: Zcount ' name ' {NUM1} {num2}

Gets the number of elements in the sorted set named name {NUM1} to {num2} sequence number (not subscript).


9. Zcard

Format: Zcard ' name '

Returns the number of elements in the sorted set named name.


Ten. Zremrangebyrank

Format: Zremrangebyrank ' name ' {NUM1} {num2} [Withscores]

Sort the sorted set named name first in ascending order, and then remove the value of the subscript {NUM1} to {num2}.





This article is from the "Bronze Gong" blog, please be sure to keep this source http://jaeger.blog.51cto.com/11064196/1772276

Redis data type operation (v)--sorted Set

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.