Skip to content

Commit 3807f2d

Browse files
committed
Add CodeBoarding documentation
1 parent 6246cba commit 3807f2d

File tree

7 files changed

+384
-0
lines changed

7 files changed

+384
-0
lines changed

CodeBoarding/Client Interface.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
```mermaid
2+
graph LR
3+
Redis_Client["Redis Client"]
4+
Connection_Pool["Connection Pool"]
5+
Connection["Connection"]
6+
Command_Parser["Command Parser"]
7+
PubSub["PubSub"]
8+
Pipeline["Pipeline"]
9+
Monitor["Monitor"]
10+
Redis_Client -- "creates" --> Connection_Pool
11+
Redis_Client -- "uses" --> Command_Parser
12+
Redis_Client -- "creates" --> PubSub
13+
Redis_Client -- "creates" --> Pipeline
14+
Redis_Client -- "creates" --> Monitor
15+
Connection_Pool -- "uses" --> Connection
16+
Pipeline -- "uses" --> Redis_Client
17+
PubSub -- "uses" --> Redis_Client
18+
Monitor -- "uses" --> Redis_Client
19+
```
20+
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/GeneratedOnBoardings)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/demo)[![Contact](https://img.shields.io/badge/Contact%20us%20-%[email protected]?style=flat-square)](mailto:[email protected])
21+
22+
## Component Details
23+
24+
The Redis client library provides a comprehensive interface for interacting with Redis servers, supporting both synchronous and asynchronous operations. It encompasses connection management, command execution, and response handling, offering features like PubSub, Pipelines, and Monitoring. The core components work together to provide a robust and efficient way to interact with Redis.
25+
26+
### Redis Client
27+
The Redis Client serves as the primary interface for interacting with a Redis server. It manages connections, executes commands, and handles responses. It supports both synchronous and asynchronous operations, allowing users to interact with Redis in a non-blocking manner. The client can be configured to connect to a single Redis instance or a Redis cluster.
28+
- **Related Classes/Methods**: `redis.client.Redis` (112:670), `redis.asyncio.client.Redis` (109:715)
29+
30+
### Connection Pool
31+
The Connection Pool manages a pool of reusable connections to the Redis server. This improves performance by reducing the overhead of establishing new connections for each request. The connection pool handles connection creation, recycling, and error handling, ensuring efficient use of resources.
32+
- **Related Classes/Methods**: `redis.connection.ConnectionPool` (1309:1654), `redis.asyncio.connection.ConnectionPool` (1031:1253)
33+
34+
### Connection
35+
The Connection class represents a single connection to the Redis server. It handles the low-level details of socket communication, including sending commands and receiving responses. It provides methods for reading and writing data to the socket, as well as handling connection errors.
36+
- **Related Classes/Methods**: `redis.connection.Connection` (730:801), `redis.asyncio.connection.Connection` (723:777)
37+
38+
### Command Parser
39+
The Command Parser is responsible for parsing the responses received from the Redis server. It converts the raw byte strings into Python data types, such as strings, integers, lists, and dictionaries. The parser handles different response formats and error conditions, ensuring that the data is correctly interpreted.
40+
- **Related Classes/Methods**: `redis.client.Redis.parse_response` (646:667), `redis.asyncio.client.Redis.parse_response` (689:715)
41+
42+
### PubSub
43+
The PubSub class provides functionality for publishing messages to channels and subscribing to channels to receive messages. It enables real-time communication between clients using the publish-subscribe pattern. It supports pattern subscriptions and message filtering.
44+
- **Related Classes/Methods**: `redis.client.PubSub` (743:1241), `redis.asyncio.client.PubSub` (803:1231)
45+
46+
### Pipeline
47+
The Pipeline class allows batching multiple commands into a single request, reducing network overhead and improving performance. It supports transactions, allowing a group of commands to be executed atomically. It also supports optimistic locking using WATCH and UNWATCH commands.
48+
- **Related Classes/Methods**: `redis.client.Pipeline` (1283:1635), `redis.asyncio.client.Pipeline` (1251:1618)
49+
50+
### Monitor
51+
The Monitor class allows you to listen to all requests received by the Redis server in real time. It's useful for debugging and monitoring Redis activity. It provides a stream of commands and their arguments as they are processed by the server.
52+
- **Related Classes/Methods**: `redis.client.Monitor` (676:740), `redis.asyncio.client.Monitor` (730:800)

CodeBoarding/Cluster Support.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
```mermaid
2+
graph LR
3+
RedisCluster["RedisCluster"]
4+
NodesManager["NodesManager"]
5+
ClusterPubSub["ClusterPubSub"]
6+
ClusterPipeline["ClusterPipeline"]
7+
PipelineStrategy["PipelineStrategy"]
8+
TransactionStrategy["TransactionStrategy"]
9+
ClusterMultiKeyCommands["ClusterMultiKeyCommands"]
10+
RedisCluster -- "manages" --> NodesManager
11+
RedisCluster -- "uses" --> ClusterPubSub
12+
RedisCluster -- "uses" --> ClusterPipeline
13+
RedisCluster -- "determines node for" --> ClusterMultiKeyCommands
14+
NodesManager -- "provides node information to" --> RedisCluster
15+
ClusterPubSub -- "executes commands" --> RedisCluster
16+
ClusterPipeline -- "executes commands" --> RedisCluster
17+
PipelineStrategy -- "implements" --> AbstractStrategy
18+
TransactionStrategy -- "implements" --> AbstractStrategy
19+
ClusterMultiKeyCommands -- "uses" --> RedisCluster
20+
```
21+
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/GeneratedOnBoardings)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/demo)[![Contact](https://img.shields.io/badge/Contact%20us%20-%[email protected]?style=flat-square)](mailto:[email protected])
22+
23+
## Component Details
24+
25+
The Cluster Support component in redis-py provides the necessary tools for interacting with Redis clusters. It abstracts the complexities of cluster management, such as node discovery, slot assignment, and command routing, offering a unified interface for both synchronous and asynchronous operations. The core of this component lies in the `RedisCluster` class, which acts as the primary client. It leverages the `NodesManager` to maintain an updated view of the cluster topology and uses strategies like `PipelineStrategy` and `TransactionStrategy` to optimize command execution. The component also includes specialized classes for pub/sub (`ClusterPubSub`) and multi-key commands (`ClusterMultiKeyCommands`), ensuring comprehensive cluster functionality.
26+
27+
### RedisCluster
28+
The RedisCluster class serves as the primary client interface for interacting with a Redis cluster. It handles connection management, command execution, and slot assignment to nodes in the cluster. It uses the NodesManager to maintain an up-to-date view of the cluster topology and routes commands to the appropriate nodes based on the key's slot. It supports both synchronous and asynchronous operations.
29+
- **Related Classes/Methods**: `redis.cluster.RedisCluster` (456:1360), `redis.asyncio.cluster.RedisCluster` (99:989)
30+
31+
### NodesManager
32+
The NodesManager class is responsible for managing the cluster's node topology. It maintains a list of all nodes in the cluster, their roles (primary or replica), and the slot ranges they serve. It dynamically updates the topology when nodes are added or removed, ensuring that the RedisCluster always has an accurate view of the cluster's structure.
33+
- **Related Classes/Methods**: `redis.cluster.NodesManager` (1443:1863), `redis.asyncio.cluster.NodesManager` (1211:1518)
34+
35+
### ClusterPubSub
36+
The ClusterPubSub class provides a client interface for interacting with Redis cluster's pub/sub functionality. It handles subscribing to channels and publishing messages to channels across the cluster, ensuring that messages are correctly routed to the appropriate nodes.
37+
- **Related Classes/Methods**: `redis.cluster.ClusterPubSub` (1866:2107)
38+
39+
### ClusterPipeline
40+
The ClusterPipeline class enables the execution of a batch of commands in a pipeline on a Redis cluster. It efficiently routes commands to the correct nodes and executes them in parallel, reducing network overhead and improving performance. It supports both synchronous and asynchronous operations.
41+
- **Related Classes/Methods**: `redis.cluster.ClusterPipeline` (2110:2299), `redis.asyncio.cluster.ClusterPipeline` (1521:1680)
42+
43+
### PipelineStrategy
44+
The PipelineStrategy class implements the AbstractStrategy interface for executing commands in a Redis cluster pipeline. It handles routing commands to the correct nodes and executing them in parallel, optimizing performance for pipelined operations.
45+
- **Related Classes/Methods**: `redis.cluster.PipelineStrategy` (2671:3018), `redis.asyncio.cluster.PipelineStrategy` (1872:2039)
46+
47+
### TransactionStrategy
48+
The TransactionStrategy class implements the AbstractStrategy interface for executing commands in a Redis cluster transaction. It ensures that all commands within the transaction are executed atomically, providing data consistency and reliability.
49+
- **Related Classes/Methods**: `redis.cluster.TransactionStrategy` (3021:3352), `redis.asyncio.cluster.TransactionStrategy` (2042:2398)
50+
51+
### ClusterMultiKeyCommands
52+
The ClusterMultiKeyCommands class provides methods for executing multi-key commands on a Redis cluster. It handles partitioning keys by slot and routing commands to the correct nodes, ensuring that multi-key operations are performed efficiently across the cluster.
53+
- **Related Classes/Methods**: `redis.commands.cluster.ClusterMultiKeyCommands` (99:260), `redis.commands.cluster.AsyncClusterMultiKeyCommands` (263:339)

CodeBoarding/Command Abstraction.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
```mermaid
2+
graph LR
3+
Command_Interface["Command Interface"]
4+
Basic_Key_Commands["Basic Key Commands"]
5+
Hash_Commands["Hash Commands"]
6+
List_Commands["List Commands"]
7+
Set_Commands["Set Commands"]
8+
Sorted_Set_Commands["Sorted Set Commands"]
9+
Stream_Commands["Stream Commands"]
10+
PubSub_Commands["PubSub Commands"]
11+
Script_Commands["Script Commands"]
12+
Basic_Key_Commands -- "Implements" --> Command_Interface
13+
Hash_Commands -- "Implements" --> Command_Interface
14+
List_Commands -- "Implements" --> Command_Interface
15+
Set_Commands -- "Implements" --> Command_Interface
16+
Sorted_Set_Commands -- "Implements" --> Command_Interface
17+
Stream_Commands -- "Implements" --> Command_Interface
18+
PubSub_Commands -- "Implements" --> Command_Interface
19+
Script_Commands -- "Implements" --> Command_Interface
20+
List_Commands -- "Uses" --> Basic_Key_Commands
21+
Set_Commands -- "Uses" --> Basic_Key_Commands
22+
Stream_Commands -- "Uses" --> Basic_Key_Commands
23+
Sorted_Set_Commands -- "Uses" --> Basic_Key_Commands
24+
Hash_Commands -- "Uses" --> Basic_Key_Commands
25+
```
26+
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/GeneratedOnBoardings)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/demo)[![Contact](https://img.shields.io/badge/Contact%20us%20-%[email protected]?style=flat-square)](mailto:[email protected])
27+
28+
## Component Details
29+
30+
The Command Abstraction component provides a unified interface for interacting with Redis, abstracting away the complexities of command encoding, decoding, and execution. It encompasses various command categories, including keys, hashes, lists, sets, sorted sets, streams, pubsub, scripts, geo, modules, and functions, offering both synchronous and asynchronous execution modes. This abstraction ensures a consistent API for developers, regardless of the underlying Redis connection type, and simplifies the process of interacting with the Redis server.
31+
32+
### Command Interface
33+
Defines the base interface for all Redis commands, providing a consistent way to execute commands and handle responses. It serves as a blueprint for concrete command implementations.
34+
- **Related Classes/Methods**: `redis.commands.core.CommandsInterface` (20:100)
35+
36+
### Basic Key Commands
37+
Implements basic key-related commands such as GET, SET, EXISTS, and DELETE. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding key values.
38+
- **Related Classes/Methods**: `redis.commands.core.BasicKeyCommands` (1557:2510)
39+
40+
### Hash Commands
41+
Implements commands for interacting with Redis hashes, including setting, getting, and deleting fields. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding hash field values.
42+
- **Related Classes/Methods**: `redis.commands.core.HashCommands` (4921:5598)
43+
44+
### List Commands
45+
Implements commands for interacting with Redis lists, including pushing, popping, and trimming elements. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding list element values.
46+
- **Related Classes/Methods**: `redis.commands.core.ListCommands` (2533:2947)
47+
48+
### Set Commands
49+
Implements commands for interacting with Redis sets, including adding, removing, and checking membership of elements. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding set element values.
50+
- **Related Classes/Methods**: `redis.commands.core.SetCommands` (3287:3462)
51+
52+
### Sorted Set Commands
53+
Implements commands for interacting with Redis sorted sets, including adding, removing, and retrieving elements with scores. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding sorted set element values.
54+
- **Related Classes/Methods**: `redis.commands.core.SortedSetCommands` (4077:4870)
55+
56+
### Stream Commands
57+
Implements commands for interacting with Redis streams, including adding messages, reading messages, and creating consumer groups. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding stream message values.
58+
- **Related Classes/Methods**: `redis.commands.core.StreamCommands` (3468:4071)
59+
60+
### PubSub Commands
61+
Implements commands for interacting with Redis's Pub/Sub functionality, including publishing messages and subscribing to channels. It interacts with the Redis client to execute these commands and provides methods for encoding and decoding pubsub messages.
62+
- **Related Classes/Methods**: `redis.commands.core.PubSubCommands` (5720:5784)
63+
64+
### Script Commands
65+
Enables the execution of Lua scripts on the Redis server. It includes functionalities for evaluating, loading, and managing scripts, providing a way to extend Redis's capabilities with custom logic.
66+
- **Related Classes/Methods**: `redis.commands.core.ScriptCommands` (5790:5928)

0 commit comments

Comments
 (0)