This project is a toy Redis clone built as part of the "Build Your Own Redis" Challenge. The implementation handles basic Redis commands like PING
, SET
, and GET
, and includes features such as reading RDB files, decoding binary data, and more.
- Command Pattern: The project uses the command pattern to handle different Redis commands. Each command is implemented as a class inheriting from an abstract
Command
class. - Asynchronous Programming: The project uses Python's
asyncio
library to handle asynchronous operations, ensuring non-blocking I/O. - RESP Protocol: The project implements the Redis Serialization Protocol (RESP) to communicate with clients.
- Observer Pattern: Allows an object to notify other objects about changes in its state.
- Singleton Pattern: Ensures ConnectionRedis class has only one instance and provides a global point of access to it.
- Command Classes: Each Redis command is implemented as a separate class (e.g.,
CommandECHO
,CommandConfigGet
). - Receiver: The receiver class handles the actual communication with the client.
- Globals: A module to store global configuration parameters.
- Reading RDB Files: Implemented functionality to read and parse Redis Database (RDB) files.
- Decoding Binary Data: Added methods to decode binary data into readable formats.
- Handling Configuration Parameters: Implemented commands to get configuration parameters like
dir
anddbfilename
. - Asynchronous Execution: Ensured that commands execute asynchronously to avoid blocking operations.
Include screenshots of your tests and their outputs here.
The replica extension enhances the Redis clone by adding support for multiple replicas. This ensures that data is synchronized across different instances, providing high availability and fault tolerance.
- Observer Pattern: The observer pattern is used to notify replicas of changes in the master instance.
- Asynchronous Programming: Python's
asyncio
library is used to handle asynchronous communication between the master and replicas. - Network Communication: Sockets are used for network communication between the master and replica instances.
- ReplicaManager: Manages the list of replicas and handles the communication between the master and replicas.
- ReplicaClient: Represents a replica instance and handles the reception of commands from the master.
- Command Synchronization: Ensures that commands executed on the master are propagated to all replicas.
- Data Consistency: Ensures that all replicas have the same data as the master.
- Fault Tolerance: Provides high availability by allowing multiple replicas to take over in case the master fails.
- Scalability: Allows the system to scale horizontally by adding more replicas.
Include screenshots of your tests and their outputs here.
- Redis Protocol Specification
- Python
asyncio
Documentation - Command Pattern
- Codecrafters Redis Challenge
- Redis RDB File Format
This error occurs if you are using a Python version older than 3.8. Upgrade to Python 3.8 or later to resolve this issue.