Redis Source Code Analysis (iv): REDIS data type hash table, list, collection, and ordered collection

Source: Internet
Author: User

The hash table is also one of the data structures supported by Redis, which uses both redis_encoding_ziplist (compressed list) and redis_encoding_ht (data Dictionary) encoding methods.

When a hash table uses a compressed list, it uses the following structure to store the data (see ZIPLIST.C):

+---------+------+------+------+------+------+------+------+------+---------+| ziplist | | | | | | | | | Ziplist | | ENTRY | Key1 | Val1 | Key2 | Val2 | ... | ... | KeyN | Valn | ENTRY | | HEAD | | | | | | | | | END |+---------+------+------+------+------+------+------+------+------+---------+

When a hash table uses a data dictionary, it uses the following structure to store the data (see DICT.C).

The list is also one of the data structures that Redis supports, encoded using both redis_encoding_ziplist (compressed list) and Redis_encoding_linkedlist (double-ended list).

The collection is also one of the data structures supported by Redis, which uses Redis_encoding_intset (integer set, intset.c) and redis_encoding_ht (data dictionary, dict.c) encoding in two ways, Use Redis_encoding_intset encoding if the first element can be represented as a long long value, otherwise use REDIS_ENCODING_HT encoding. The operation that can be performed on it.

An ordered set (that is, Zset) is also one of the data structures supported by REDIS, encoded using redis_encoding_ziplist (compressed table) and redis_encoding_skiplist (jumping table, zskiplist). It differs from the set in that it adds a score field to the order.



Redis Source Code Analysis (iv): REDIS data type hash table, list, collection, and ordered collection

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.