Design and Implementation of Redis - list and dictionary

1. list

1.1 linked list structure

In Redis, the linked list is a doubly linked list to achieve, except that a conventional chain is that it has three different function pointer, the function for copying DUP value stored in the node list, free function releases the stored list node values, match function value and another value for the comparison list node are equal.

1.2 summary

2. Dictionary

2.1 dictionary definition

Similar Redis dictionary for C ++ map, key value and associating dictionary may comprise a plurality of pairs.

Hash table to achieve 2.2

Redis underlying dictionary implemented as a hash table, a hash table has a plurality of hash nodes, each node holds a hash key-value pair. Redis hash table structure is defined as follows.

Wherein the table is a dictEntry array, each element holds a key-value pair dictEntry structure is defined as follows.

To prevent conflict hash key is pressed, dictEntry design of a next field, forming a linked list, the structure as shown in FIG key violation,

2.3 Dictionary

 

Guess you like

Origin www.cnblogs.com/lawliet12/p/10956452.html