Skip to content

ParvePalial/MiniRedis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-Redis (C++ Key-Value Store)

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.

System Architecture

  • O(1) Memory Engine: Fuses a std::unordered_map with a custom Doubly Linked List to create an LRU (Least Recently Used) cache. When memory hits capacity, the oldest data is evicted in strict O(1) time.
  • Concurrency / Thread Safety: Utilizes C++ std::mutex and std::lock_guard to 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 .aof file on the hard drive, allowing the database to perfectly recover from sudden crashes or power outages.

How to Build and Run

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

About

Mini-Redis (in-memory c++ Key-Value database)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors