redis--Internal Structure--ziplist

Source: Internet
Author: User
Tags redis

A compressed list is one of the underlying implementations of the list key and hash keys.
The compression list is a sequential data structure composed of a series of specially coded contiguous blocks of memory, developed by Redis to conserve memory.
1, the composition of the compression list


2, the composition of the compressed list node

<1>previous_entry_length
The length of the previous node in the compressed list is recorded in bytes. can be 1 bytes or 5 bytes, the previous node is less than 254Byte can be saved with 1 bytes, the previous byte is greater than or equal to 254Byte can be saved with 5 bytes of its length. With this length, the compression list can be traversed from the beginning to the tail, or from the given pointer through the head or tail;
<2>encoding
Records the type and length of data held by the content property of a node, one byte, two bytes, five bytes long, the highest bit of the value 00, 01, and 10 for byte array encoding, and in addition to the highest bit record type, the length of the byte array is recorded by the remaining bits, and the highest bit of the value begins with 11. denotes integer encoding;
<3>content
Save the value of the node;

3. Chain Update
In order to satisfy the previous node, the current node is amplified, and finally the node size is updated for each node of the entire list, which is the chain update; the addition or deletion of nodes can cause cascading updates.
Causes of cascading updates:
<1> first of all, in the compression list there are just a number of contiguous, length between 250 bytes to 253 bytes of nodes, chain updates can occur, in practice, this situation is not much see;
<2> second, even if there is a chain update, but as long as the number of nodes updated, there will be no impact on performance;

Design and implementation of Redis

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.