A C++ implementation for redis server
To build this Redis server implementation, follow these steps:
-
Ensure you have the following prerequisites installed:
- C++ compiler with C++17 support (e.g., GCC 7+ or Clang 5+)
- CMake (version 3.10 or higher)
-
Clone the repository:
git clone https://github.com/yourusername/redis-server.git cd redis-server
-
Create a build directory and navigate to it:
mkdir build cd build
-
Generate the build files using CMake:
cmake ..
-
Build the project:
make
-
After successful compilation, you'll find the executable in the
build
directory. -
Run the server:
./server
For all available options:
./server -h
- Add GUI to visualize server, clients and stored records. imGui
A: This implementation supports basic Redis commands such as PING, ECHO, GET, SET, CONFIG, KEYS, and INFO. For a complete list of supported commands, please refer to the initCmdsLUT
function in the src/RedisServer.cpp
file.
A: Yes, this implementation includes basic support for Redis replication. It can be configured as a replica and connect to a master server. The replication functionality can be found in the handShakeMaster
method of the Server
class.
A: Commands are processed using a lookup table (LUT) that maps command names to their corresponding handler functions. When a command is received, the server looks up the appropriate handler in the cmdsLUT
and executes it.
A: Yes, this implementation supports key expiration. When setting a key, an optional expiry time can be provided. The getValue
method checks for key expiration before returning a value.
A: Contributions are welcome! Please fork the repository, make your changes, and submit a pull request. Make sure to follow the existing code style and include appropriate tests for new features.
A: Everything is production ready if you are brave enough.