Redis State¶
State manager using redis
RedisState
¶
Bases: State
RedisState: A state manager that stores state in Redis.
This manager provides a fast, in-memory storage solution using Redis.
Attributes:
Name | Type | Description |
---|---|---|
redis |
redis.Redis
|
The Redis connection. |
__init__(task_id, host, port, db)
¶
Initialize a new Redis state manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
str
|
The task identifier. |
required |
host |
str
|
The host of the Redis server. |
required |
port |
int
|
The port of the Redis server. |
required |
db |
int
|
The database number to connect to. |
required |
get(task_id, key)
¶
Get the state associated with a task and key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
str
|
The task identifier. |
required |
key |
str
|
The key to get the state for. |
required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: The state associated with the task and key, if it exists. |
set(task_id, key, value)
¶
Set the state associated with a task and key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
str
|
The task identifier. |
required |
key |
str
|
The key to set the state for. |
required |
value |
Dict[str, Any]
|
The state to set. |
required |