Skip to content

DongInSong/mini-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-Redis

License Last Commit

Project Report (한국어)

Full Project Report

1. Overview

C++와 Boost.Asio를 사용하여 Redis의 핵심 기능(GET, SET, PUB/SUB, TTL 등)을 구현하는 학습용 프로젝트입니다.
A learning-oriented project that implements core Redis features (GET, SET, DEL, PUB/SUB, TTL, etc.) using C++ and Boost.Asio.

2. Tech Stack

C++ Boost

3. Project Structure

.
├── client/               # Source code for the test client
├── docs/                 # Project-related documentation
├── include/              # Header files
│   ├── command/          # Classes for handling commands (e.g., PING, GET, SET)
│   ├── config/           # Manages server configuration (from config.yaml)
│   ├── network/          # Asynchronous network communication (TCP server, sessions)
│   ├── protocol/         # RESP (Redis Serialization Protocol) parser and serializer
│   ├── pubsub/           # Manages Publish/Subscribe functionality
│   └── storage/          # In-memory Key-Value data store
├── src/                  # Source files (implementation)
│   ├── command/
│   ├── config/
│   ├── network/
│   ├── protocol/
│   ├── pubsub/
│   ├── storage/
│   └── main.cpp          # Server application entry point
├── tests/                # Unit tests using GTest
├── .gitignore
├── CMakeLists.txt        # CMake build script
├── config.yaml           # Server host and port configuration file
└── README.md

4. Project Progress progress

Milestone 1: TCP Server and PING Command

  • Asynchronous TCP Server: Built a basic asynchronous TCP server using Boost.Asio to support multiple simultaneous client connections.
  • TCP Client Implementation: Created a simple synchronous client to connect, send commands, and receive responses from the server.
  • RESP Parser: Implemented a parser to decode RESP (REdis Serialization Protocol) array format commands.
  • Command Handler: Developed a command handler structure to process parsed commands.
  • PING Command: Implemented the PING command to validate the communication and command flow between the client and server.

Milestone 2: Basic Data Operations

  • In-memory Data Store: Implement an internal store to manage key-value data.
  • SET Command: Implement storing a value for a specified key.
  • GET Command: Implement retrieving the value of a specified key.
  • DEL Command: Implement key deletion. Returns the number of keys that were removed.
  • KEYS Command: Implement key searching with glob-style patterns (e.g., KEYS *, KEYS user:*).

Milestone 3: Advanced Features

  • PUB/SUB Commands: Implement publish/subscribe messaging functionality.
  • TTL (Time To Live): Implement expiration for keys.

Milestone 4: Integration with RSS-Redis Project

  • Apply to GitHub and compare performance with existing Redis.

5. Build & Execution

Requirements

  • C++17 compatible compiler (MSVC, GCC, Clang)
  • CMake (3.10 or higher)
  • vcpkg package manager

Build Steps

  1. Install Dependencies with vcpkg The project requires boost, gtest (for tests), and yaml-cpp.

    # From your vcpkg directory
    # For Windows
    ./vcpkg install boost:x64-windows gtest:x64-windows yaml-cpp:x64-windows
    
    # For Linux / macOS
    ./vcpkg install boost gtest yaml-cpp
  2. Clone the Repository

    git clone https://github.com/DongInSong/mini-redis.git
    cd mini-redis
  3. Configure the Build with CMake
    The project will automatically find the vcpkg toolchain if you have the VCPKG_ROOT environment variable set.

    mkdir build
    cd build
    cmake ..

    If you do not have the VCPKG_ROOT environment variable set, you must specify the path to the toolchain file manually:

    # Replace <path-to-vcpkg> with the actual path to your vcpkg installation
    cmake .. -DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake
  4. Build the Project

    cmake --build .

    Executables will be generated in the build/Debug (or build/Release) directory.

Run

  1. (Optional) Modify Configuration Edit config.yaml in the project root to change the server's host or port.

    server:
      host: 0.0.0.0
      port: 6379
  2. Start the Server The server executable must be run from the project root directory to find config.yaml.

    # From the 'build' directory
    ./Debug/mini-redis_server
  3. Start the Client Open a new terminal to connect to the server.

    # From the 'build' directory
    ./Debug/client

6. Future Plans

  • Support for various data structures (List, Hash, Set, Sorted Set).
  • Implement advanced logging system (e.g., spdlog).
  • Implement persistence (RDB or AOF).

About

c++ mini redis

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published