ℹ️ New Book: Build Your Own Database
Build Your Own Redis with C/C++
Learn network programming and data structures by coding from scratch.
Introduction
- Why build Redis? The knowledge required is broader and deeper than usual application-level development. It’s a good way to level up your skills (mainly network programming and data structures).
- Why from scratch? A quote from Richard Feynman: “What I cannot create, I do not understand”. Human understandings are filled with holes aka “things I don’t know I don’t know”. Building from scratch is a way to ensure your understanding is complete.
- Why C? C is widely used in system programming and infrastructure software. Learn how C is used in real projects, with straightforward C code. No prior C/C++ experience is required.
- Why a book? The Redis project is a complex software system built with lots of effort, which can be harder to grasp for beginners. The book breaks down the core concepts into easy-to-digest steps.
Table of Contents
Part 1. Getting Started
- Introduction
- Introduction to Sockets
- Hello Server/Client
- Protocol Parsing
- The Event Loop and Nonblocking IO
- The Event Loop Implementation
- Basic Server: get, set, del
Part 2. Essential Topics
- Data Structure: Hashtables
- Data Serialization
- The AVL Tree: Implementation and Testing
- The AVL Tree and the Sorted Set
- The Event Loop and Timers
- The Heap Data Structure and the TTL
- The Thread Pool and Asynchronous Tasks
(The book is complete at this point.)
Appendixes
Source code: https://build-your-own.org/redis/src.tgz.
The book is available for purchase.
See also:
codecrafters.io offers “Build Your Own X” courses in many programming languages.
Including Redis, Git, SQLite, Docker, and more.
Check it out
codecrafters.io offers “Build Your Own X” courses in many programming languages.
Including Redis, Git, SQLite, Docker, and more.