Design and Implementation of Redis - realization of the data structure (D) Packing List

Ziplist Redis is implemented for a small number of items of the list and hash list for implementation, the data structure of the contiguous block of memory composed mainly to save memory, not a struct:

Wherein the value entry for each node:

Wherein a node before previous_entry_length for holding the length of the current node a length of 254, this property has only one byte, otherwise the attribute consists of 5 bytes, of which the first byte is 0XFE. This property of course, to the front from the list traversed.

Chain Update

       What is the chain update it? Is interjected a length greater than a list element 254 (or suddenly remove a small element) update the node chain length results, this will result in complexity of O (N ^ 2) time, which is the worst case time complexity .

Published 47 original articles · won praise 8 · views 30000 +

Guess you like

Origin blog.csdn.net/nanchengyu/article/details/89321206