Introduction
- Why build Redis? Redis exposes you to basic data structures and system programming (mainly network programming), both of which are overlooked by most developers. You can study 2 important subjects in 1 project.
- Why from scratch? A quote from Richard Feynman: “What I cannot create, I do not understand”. Reading about things often just gives you an illusion of knowledge. Learn deeper by doing!
- Why C? C was, is, and will be widely used for system programming and infrastructure software. And C is unavoidable for learning low-level stuff. Learn C today and you’ll appreciate in the future.
- Why a book? The real Redis project is a large code base built with lots of effort. The book isolates the core concepts and guides you through small steps.
Table of Contents
Part 1. Redis from 0 to 1
- Introduction
- Socket Programming Concepts
- TCP Server and Client
- Application Protocol
- The Event Loop and Nonblocking IO
- The Event Loop Implementation
- Basic Server: get, set, del
Part 2. Advanced Topics
- Data Structure: Hashtables
- Data Serialization
- The AVL Tree: Coding & Testing
- Sorted Set From AVL Tree
- The Event Loop and Timers
- The Heap Data Structure and the TTL
- The Thread Pool and Asynchronous Tasks
Source Code
https://build-your-own.org/redis/src.tgz
PDF/EPUB and Paperback Editions
The book is available for purchase.
Recommended Reading
I have curated a list of books that are highly relevant for people who intend to DIY their own Redis.
Beej’s Guide to Network
Programming. [Amazon] [Web] A comprehensive guide and reference to network programming. It’s a great supplement for coding your own networked apps, as the Redis book doesn’t cover all the details of socket programming. |
|
The Linux Programming
Interface by Michael Kerrisk. [Amazon] [Web] The socket API is only a subset of the Linux API interface. You will probably need to become familiar with the other parts, such as IOs, threads and processes, signals, and etc, if you are developing apps for Linux. |
|
The C Programming
Language by K&R. [Amazon] Are you scared of C, but still want to follow the project? No problem. This classic book is great for picking up C quickly, whether you are a beginner or an experienced developer. |