Redis open-source document redis Design and Implementation

Source: Internet
Author: User

Redis is one of the most widely used nosql products. The current stable version is 2.6.10, including GitHub, Instagram, blizzard, and Sina Weibo. redis is widely used in products. ItsCodeBased on the BSD Protocol open source, the entire project has only over 20 thousand lines of code (Version 2.2 ), you can read the code to learn the author's design philosophy and the implementation of redis in a relatively short period of time, so that you can understand it.

Today, huangz released the open-source document redis design and implementation.Source codeI started to learn about the redis notes collection. For the purpose of writing this document, the author said:

The goal of this book is to explain the internal operation mechanism of redis in a concise and easy-to-understand manner. by reading this book, you can understand almost all the knowledge of redis from data structures to server structures.

Redis design and implementation describes the implementation of redis in five aspects:

    1. Internal Data Structure
    2. Memory ing Data Structure
    3. Redis Data Type
    4. Function implementation
    5. Some Operating Mechanisms

At the same time, the author also gives a detailed comment on the source code of redis 2.6 to meet the needs of deep learning.

Huang jianhong (huangz), author of redis design and implementation, is a 90-Year-Old user who prefers functional programming. He began to read redis source code only when he was interested in the database, he looks at the entire reading process as follows:

Reading redis source code is a brand new learning experience for me. When I first looked at the redis source code, I only had some basic data structures andAlgorithmWithout any experience in network programming, database, or system programming, it is basically just a matter of looking at the source code while supplementing the basic knowledge.

When asked how to read the source code of an open-source project, he shared his methods:

  1. Bottom-up: read from the module with the smallest coupling relationship, and then gradually over to the closely related module. It's like writingProgramThe unit test starts before the function test. When I first started reading the redis source code, I used this method: first starting from a separate data structure module, and then transitioning to a high-level functional module.

  2. Start with the function: Quickly locate the specific implementation of a function through the file name (Module name) and function name, and then track the entire implementation process to learn how this function is implemented. This method is used when I read a blocking list, database, and other modules that are more coupled with other files.

  3. Top-down: from the main () function of the program, or a very large caller function as the entry, read its source code in depth-first or breadth-first mode. I am reading redis. c/servercron (), redis. c/main () and AE. this method is used when C/aemain () is a function with obvious caller nature.

Then he stressed:

These three methods do not conflict with each other: some functions/modules must use some method, while some functions/modules must use another method, and sometimes multiple methods need to be mixed.

It is worth mentioning that this book has been open-source in the form of "reserve all rights". You can view the content creation process on GitHub, at the same time, this open-source collaboration method allows more people to participate in content optimization.

original address: http://www.infoq.com/cn/news/2013/03/redis-book

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.