Skip to content

Simioniuc-Ionut/Redis-project-python

Repository files navigation

Project Documentation

Overview

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.

Implementation Details

Concepts Used

  1. 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.
  2. Asynchronous Programming: The project uses Python's asyncio library to handle asynchronous operations, ensuring non-blocking I/O.
  3. RESP Protocol: The project implements the Redis Serialization Protocol (RESP) to communicate with clients.
  4. Observer Pattern: Allows an object to notify other objects about changes in its state.
  5. Singleton Pattern: Ensures ConnectionRedis class has only one instance and provides a global point of access to it.

Key Components

  • 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.

Problems Solved

  1. Reading RDB Files: Implemented functionality to read and parse Redis Database (RDB) files.
  2. Decoding Binary Data: Added methods to decode binary data into readable formats.
  3. Handling Configuration Parameters: Implemented commands to get configuration parameters like dir and dbfilename.
  4. Asynchronous Execution: Ensured that commands execute asynchronously to avoid blocking operations.

Testing and Output

Screenshots

Include screenshots of your tests and their outputs here.

Test Output 1 Test Output 2 Test Output 3 Test Output 4 Test Output 5 Test Output 6 Test Output 7 Test Output 8 Test Output 9 Test Output 10 Test Output 11 Test Output 12 Test Output 13

Replica Extension

Overview

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.

Implementation Details

Concepts Used

  1. Observer Pattern: The observer pattern is used to notify replicas of changes in the master instance.
  2. Asynchronous Programming: Python's asyncio library is used to handle asynchronous communication between the master and replicas.
  3. Network Communication: Sockets are used for network communication between the master and replica instances.

Key Components

  • 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.

Problems Solved

  1. Data Consistency: Ensures that all replicas have the same data as the master.
  2. Fault Tolerance: Provides high availability by allowing multiple replicas to take over in case the master fails.
  3. Scalability: Allows the system to scale horizontally by adding more replicas.

Testing and Output

Screenshots

Include screenshots of your tests and their outputs here. Test Output 14

Test Output 15 Test Output 16

Test Output 17

Test Output 18

Test Output 19 Test Output 20

Test Output 21 Test Output 22

Test Output 23

Test Output 24 Test Output 25 Test Output 26

Test Output 27 Test Output 28 Test Output 29 Test Output 30 Test Output 31 Test Output 32

References

Troubleshooting

Common Issues

module 'socket' has no attribute 'create_server'

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •