@GYLQ520: 学网络编程的人,老是栽在同一个坑里—— 理论看完了还是写不出来,源码读完了也不知道从哪儿下手改。 直到我翻到这个开源的宝藏教程:Build Your Own Redis,手把手带你从零硬肝出一个真正能跑的 Redis 服务器。 路线分两段…
摘要
这个开源教程《Build Your Own Redis》教你手把手从零用C/C++实现一个功能完备的Redis服务器,深入讲解网络编程、数据结构和底层C语言,配有代码和详细说明。
查看缓存全文
缓存时间: 2026/06/17 01:44
学网络编程的人,老是栽在同一个坑里——
理论看完了还是写不出来,源码读完了也不知道从哪儿下手改。
直到我翻到这个开源的宝藏教程:Build Your Own Redis,手把手带你从零硬肝出一个真正能跑的 Redis 服务器。
路线分两段:
先拿 socket 编程开刀,TCP 服务器、事件循环、键值存储,一层层往上搭 再往硬核里冲,哈希表、AVL 树、线程池,真正把底层啃明白
每章都带着代码 + 讲解,拆得够细,步子踩得够稳,跟着撸完你会发现自己是真懂了,不是那种“感觉懂了”。
免费网页版直接看: https://build-your-own.org/redis/
Build Your Own Redis with C/C++ | Build Your Own Redis with C/C++
Source: https://build-your-own.org/redis/
Introduction
Buildreal-worldsoftware by codingfrom scratch.**If you can build a Redis server, you can build almost any software beyond CRUD!**Because it teaches you 3 fundamental skills:
- Network programming. The next level of programming is programming for multiple machines. Think HTTP servers, RPCs, databases, distributed systems.
- Data structures. Redis is the best example of applying data structures to real-world problems. Why stop at theoretical, textbook-level knowledge when you can learn from production software?
- Low-level C. C was, is, and will be widely used for systems programming and infrastructure software. It’s a gateway to many low-level projects.
**Why from scratch?**A quote from Richard Feynman: “What I cannot create, I do not understand”. You should test your learning with real-world projects!
**Why a book?**The real Redis project is a large code base built with lots of effort. The book distills the core concepts and guides you throughsmall steps.
Table of Contents
Part 1. Redis from 0 to 1
- Introduction
- Socket Programming
- TCP Server and Client
- Request-Response Protocol
- Concurrent IO Models
- Event Loop (Part 1) Event Loop (Part 2)
- Key-Value Server
Part 2. Advanced Topics
- Hashtables (Part 1) Hashtables (Part 2)
- Data Serialization
- Balanced Binary Tree
- Sorted Set
- Timer and Timeout
- Cache Expiration with TTL
- Thread Pool
Source Code
https://build-your-own.org/redis/src.tgz
PDF/EPUB and Paperback Editions
The full book is free in web version. You can**purchase**the book if you find the book helpful.
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 Interfaceby 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 Languageby 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.
相似文章
@yupi996: https://x.com/yupi996/status/2064510096516981231
程序员鱼皮分享了一份保姆级教程,教国内用户如何顺利使用Claude Code和Codex进行AI编程,解决网络访问问题。
@CycleDecoded: 离谱了!搜狐直接把自家压箱底的 Redis 云平台给开源了。这波算是把后端老哥的饭碗给端了级别的自动化。 项目叫 CacheCloud,是搜狐视频内部扛过每天 800 亿次请求、18T 内存的怪物。现在直接扔在 GitHub 上,狂揽近 …
搜狐开源了其内部Redis云管理平台CacheCloud,支持单机、哨兵、集群模式,提供一键搭建、监控告警、弹性扩容等功能,已在GitHub获得近9000星,采用Apache-2.0协议。
@Ryrenz: 兄弟们,又挖到一个宝藏课程:7 周从零搭出一套生产级 RAG 系统 GitHub 上 7.7k stars,全程动手写代码,不是幻灯片课 市面上的 RAG 教程大多直奔向量检索,demo 能跑,但是上线就崩。 这门课走的是公司里真实的路径…
一个GitHub上7.7k stars的7周课程,从零搭建生产级RAG系统,涵盖Docker、FastAPI、混合检索、LangGraph agentic RAG和Telegram bot,全程动手写代码。
@WWTLitee: 推荐一个超屌的东西:codecrafters-io/build-your-own-x 目前 513k+ Stars 简单说他就是一个造一切的说明书,你想造啥就能造啥 它不是一个工具,而是一份“从零造轮子”的学习路线合集 自己写数据库、浏览…
介绍 codecrafters-io/build-your-own-x 仓库,一个收集了从零开始构建各种技术的教程合集,帮助开发者通过动手实践来理解底层原理。
@Jolyne_AI: 学完 C 语言语法,却卡在「不知道写什么」?网上教程又零散、难串成体系。 Project Box 把这件事做成了:一套为 C 初学者整理好的项目合集,从入门到进阶一路带你练到会。共 10 个不同难度的项目,从井字棋到网络编程,每个都有源码…
Project Box是一个为C语言初学者设计的项目合集,包含10个不同难度的项目,从井字棋到网络编程,每个项目都有源码、文档和构建配置,帮助学习者通过实践掌握C语言。
