Back to previous page
C++POSIX SOCKETSMULTITHREADINGDOCKERCI

MINI-
REDIS.

A persistent, multithreaded key-value store built from scratch to understand networking, concurrency, expiration and persistence beneath a familiar database abstraction.

ROLESOFTWARE ENGINEER / BUILDER
COREC++ · POSIX SOCKETS · THREADS
DATAIN-MEMORY KEY-VALUE STORE · TTL
PERSISTENCEWRITE-ON-CLOSE SNAPSHOT
DELIVERYDOCKER · DOCKER COMPOSE · GITHUB ACTIONS

I WANTED TO UNDERSTAND THE MACHINERY, NOT JUST CALL AN API.

Mini-Redis turns that curiosity into a working networked service. Clients connect over TCP, commands are parsed and executed against shared in-memory state, keys can expire, and the store can persist its state to disk.

REQUEST → EXECUTION → STATEMINI-REDIS / SYSTEM MAP
TCP CLIENTSConcurrent network connections
COMMAND PROTOCOLSET / GET / DEL / EXISTS
KVSHARED STATE
THREADSstd::thread per client
PERSISTENCESnapshot on shutdown
SETStore / replace a value.
GETRead the current value.
DELDelete a key.
EXISTSCheck whether a key exists.
EXPIREAttach a lifetime to a key.
TTLInspect remaining lifetime.
KEYSInspect available keys.
TCPClient/server communication.
NETWORKING

A custom TCP server accepts client connections through POSIX sockets and turns byte streams into commands.

CONCURRENCY

Each client is handled with std::thread while shared state is protected with std::shared_mutex.

THREAD SAFETY

Read and write paths are coordinated around shared in-memory state.

TTL

Keys can carry expiration metadata and expose remaining lifetime through TTL.

PERSISTENCE

State is written to disk as a snapshot when the server closes.

DELIVERY

Multi-stage Docker packaging, Docker Compose and GitHub Actions make the service reproducible and checked.

The project is small, but the lessons are not. Building the pieces directly made concurrency, sockets, resource ownership, persistence and lifecycle decisions concrete instead of theoretical.

Explore the implementation and project history in the repository.

View on GitHub ↗