SORTEDSET for Redis data type, redissortedset

Source: Internet
Author: User

SORTEDSET for Redis data type, redissortedset

Web programmer blog: http://blog.csdn.net/thinkercode

Sorted set type-Features

Sorted set is an upgraded version of set. It adds an ordered Attribute Based on set. This attribute can be specified when you add or modify elements. After each attribute is specified, zset automatically re-adjusts the order according to the new value. It can be understood that there are two columns of mysql tables, one column stores value and one column stores order. In the operation, the key is interpreted as the zset name.
Similar to set, sorted set is also a set of string elements. The difference is that each element is associated with a score of the double type. The implementation of sorted set is a mixture of skip list and hash table.
When an element is added to a set, the score ing from an element to score is added to the hash table. Therefore, the overhead for getting score from an element is O (1 ), another score-to-element ing is added to the skip list and sorted by score. Therefore, you can obtain elements in the Set in sequence. The overhead of adding and deleting operations is the same as that of O (log (N) and skip list. redis's skip list is implemented using a two-way linked list, so that elements can be retrieved from the tail in reverse order. Sorted set is most frequently used as an index. We can store the fields to be sorted as scores, and the Object id is stored as an element. The following are the commands related to sorted set.

Common sorted set commands

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.