Skip to content

Paritoshcodes/mini-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

mini-redis

A Redis clone built from scratch in C++, following the internals of how Redis actually works — TCP sockets, the RESP wire protocol, in-memory storage, key expiry, and an event-driven I/O loop.

Why I'm building this

I wanted to understand what happens below the API — how a server actually accepts connections, reads bytes off the wire, parses a protocol, and responds. This repo documents that learning process commit by commit.

Build roadmap

Part What gets built Status
1 TCP server — socket, bind, listen, accept ✅ Done
2 Read loop — recv(), raw RESP bytes visible ✅ Done
3 RESP parser — decode arrays, bulk strings ✅ Done
4 Commands — PING, ECHO ✅ Done
5 In-memory store — SET, GET, DEL ✅ Done
6 Key expiry — EX, PX, TTL ✅ Done
7 Concurrent clients — epoll event loop ✅ Done

How to build and run

g++ -o mini-redis server.cpp
./mini-redis

Then in a second terminal:

redis-cli ping     # should return PONG
redis-cli set name paritosh
redis-cli get name

Tech

  • Language: C++
  • OS: Linux (uses POSIX socket APIs)
  • Tested on: Kali Linux

What I'm learning

  • How TCP servers work at the syscall level (socket, bind, listen, accept, recv, send)
  • The RESP (Redis Serialization Protocol) wire format
  • How std::unordered_map backs a key-value store
  • Non-blocking I/O with epoll
  • How std::chrono enables TTL/expiry logic

About

Building a Redis clone from scratch in C++ — learning TCP, RESP protocol, and event-driven I/O step by step

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages