peyk.fsm.storage.redis¶
Optional Redis-backed FSM storage.
Classes
|
Minimal async Redis surface required by |
|
Persist FSM state/data in Redis with independent optional TTLs. |
- class peyk.fsm.storage.redis.AsyncRedisClient(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal async Redis surface required by
RedisStorage.- async get(key: str) str | bytes | None[source]¶
Performs the get operation for the FSM client.
- Parameters:
key – Value used by this operation.
- Returns:
Result produced by the FSM operation.
- async set(key: str, value: str, *, ex: int | float | None = None) object[source]¶
Performs the set operation for the FSM client.
- Parameters:
key – Value used by this operation.
value – Value used by this operation.
ex – Value used by this operation.
- Returns:
Result produced by the FSM operation.
- class peyk.fsm.storage.redis.RedisStorage(redis: AsyncRedisClient | None = None, *, state_ttl: int | float | None = None, data_ttl: int | float | None = None, key_builder: KeyBuilder | None = None, url: str | None = None, prefix: str | None = None)[source]¶
Bases:
BaseStoragePersist FSM state/data in Redis with independent optional TTLs.
- async get_state(key: StorageKey | str) str | None[source]¶
Return a stored state string, if present.
- async set_state(key: StorageKey | str, state: str | None) None[source]¶
Set or clear state, applying
state_ttlwhen configured.
- async get_data(key: StorageKey | str) dict[str, object][source]¶
Decode JSON conversation data from Redis.
- async set_data(key: StorageKey | str, data: Mapping[str, object]) None[source]¶
Replace JSON conversation data and apply
data_ttl.
- async update_data(key: StorageKey | str, data: Mapping[str, object] | None = None, **kwargs: object) dict[str, object][source]¶
Read, merge and persist conversation data.