A lightning-fast, multi-threaded, in-memory Key-Value database written entirely from scratch in C++. I built this project to bridge the gap between abstract algorithmic concepts and real-world systems engineering. It implements its own TCP networking layer, handles concurrency with mutex locks, and guarantees O(1) data eviction using a custom LRU cache architecture.
- O(1) Memory Engine: Fuses a
std::unordered_mapwith a custom Doubly Linked List to create an LRU (Least Recently Used) cache. When memory hits capacity, the oldest data is evicted in strictO(1)time. - Concurrency / Thread Safety: Utilizes C++
std::mutexandstd::lock_guardto prevent race conditions and Segmentation Faults when multiple clients attempt to read/write simultaneously. - Networking Layer: Uses POSIX TCP Sockets (
sys/socket.h) to bind to a port and listen for incoming client streams, parsing raw bytes into executable commands. - Disk Persistence (WAL): Implements a Write-Ahead Log (Append-Only File). Volatile RAM state is safely serialized to a
.aoffile on the hard drive, allowing the database to perfectly recover from sudden crashes or power outages.
You don't need any external dependencies. Just standard C++ and Linux/macOS.
# Clone the repo
git clone [https://github.com/<YOU>/mini-redis.git](https://github.com/<YOU>/mini-redis.git)
cd mini-redis
# Build the executable using the Makefile
make
# Run the server
./mini-redis