Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-Redis C++

An in-memory Key-Value server written in C++, developed using a modular Object-Oriented Programming (OOP) architecture. The project supports concurrent multi-threading, thread-safe synchronization, and disk data persistence.

Project Structure

The project is organized into separate modules for networking and data management:

mini-redis-cpp/ ├── .vscode/ # VS Code editor settings ├── .gitignore # Git rules to ignore binaries and temporary files ├── Database.h # Database class declaration (data interface) ├── Database.cpp # Implementation of storage, synchronization, and disk I/O ├── Server.h # Server class declaration (network interface) ├── Server.cpp # Implementation of TCP sockets and thread management ├── main.cpp # Application entry point ├── database.txt # Persistence file (local data storage) ├── main.exe # Compiled executable └── README.md # Project documentation

Features

  • OOP Architecture: Clear separation between the data module (Database) and the network module (Server).
  • Thread Safety: Data protection during concurrent access using std::mutex and std::lock_guard.
  • Multi-threading: Each connected client is handled on a dedicated thread (std::thread).
  • Persistence: Automatic saving of changes to database.txt and automatic loading into memory upon server startup.
  • TCP Protocol: Communication via Winsock2 sockets on port 6379.

Supported Commands

  • SET : Stores the key-value pair in memory and on disk.
  • GET : Returns the value associated with the key or an error message.
  • DEL : Removes the key from memory and updates the file.
  • EXIT : Closes the current client connection.

Compilation and Execution

Prerequisites

  • C++ compiler (MinGW / g++) with C++11 support or newer.
  • Winsock2 library (ws2_32) on Windows systems.

Compilation

Open a terminal in the project directory and run:

g++ *.cpp -o main.exe -lws2_32

Execution

Once compiled successfully, start the server:

.\main.exe

The server will listen for incoming connections on port 6379.

Connecting and Testing

You can connect using a RAW socket client such as PuTTY:

  1. Host Name: 127.0.0.1 or localhost
  2. Port: 6379
  3. Connection type: Raw
  4. Click Open and send interactive commands (SET, GET, DEL, EXIT).

About

A modular, multi-threaded C++ in-memory key-value store with TCP sockets and disk persistence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages