Go deep into the underlying C source code and explain the core design principles of Redis

Table of contents

1. Basic features of redis

 2. Redis application scenario

3. Data structure

 3.1 string


1. Basic features of redis

 2. Redis application scenario

 

3. Data structure

 3.1 string

In redis, there is a kv structure, the key is a string structure at the bottom, and the value includes string, hash, set, sorted set, list, etc.

The data structure in string is as follows. Before 3.2, there were only three parameters: len (character length), free (free space), and buf[] (storage variable)

Three characteristics of string strings in redis

1. Binary safe data structure

        The c language uses a \0 to represent the end of the structure such as string str='xxx\0';

2. Provides a memory pre-allocation mechanism to avoid frequent memory allocation

        Provide expansion mechanism, algorithm: (len+addlen)*2

3. Function library compatible with C language.

 The bottom layer of bitmap uses string, and the maximum length that string can represent is 512M.

The figure below counts weekly active users

Guess you like

Origin blog.csdn.net/qq_21575929/article/details/125577434