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.
.
├── 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
- 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.
-
PINGCommand: Implemented thePINGcommand to validate the communication and command flow between the client and server.
- In-memory Data Store: Implement an internal store to manage key-value data.
-
SETCommand: Implement storing a value for a specified key. -
GETCommand: Implement retrieving the value of a specified key. -
DELCommand: Implement key deletion. Returns the number of keys that were removed. -
KEYSCommand: Implement key searching with glob-style patterns (e.g.,KEYS *,KEYS user:*).
-
PUB/SUBCommands: Implement publish/subscribe messaging functionality. - TTL (Time To Live): Implement expiration for keys.
- C++17 compatible compiler (MSVC, GCC, Clang)
- CMake (3.10 or higher)
- vcpkg package manager
-
Install Dependencies with vcpkg The project requires
boost,gtest(for tests), andyaml-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
-
Clone the Repository
git clone https://github.com/DongInSong/mini-redis.git cd mini-redis -
Configure the Build with CMake
The project will automatically find the vcpkg toolchain if you have theVCPKG_ROOTenvironment variable set.mkdir build cd build cmake ..If you do not have the
VCPKG_ROOTenvironment 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
-
Build the Project
cmake --build .Executables will be generated in the
build/Debug(orbuild/Release) directory.
-
(Optional) Modify Configuration Edit
config.yamlin the project root to change the server's host or port.server: host: 0.0.0.0 port: 6379
-
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 -
Start the Client Open a new terminal to connect to the server.
# From the 'build' directory ./Debug/client
- Support for various data structures (List, Hash, Set, Sorted Set).
- Implement advanced logging system (e.g., spdlog).
- Implement persistence (RDB or AOF).