In-memory State¶
State manager using local memory
InMemoryState
¶
Bases: State
🧠 InMemoryState: A state manager that stores state in memory.
This manager is useful for temporary storage or testing purposes. Since it's in-memory, the data will be lost once the application stops.
Attributes:¶
store
(Dict[str, Dict]): The in-memory store for states.
Usage:¶
manager = InMemoryState()
manager.set_state("user123", {"status": "active"})
state = manager.get_state("user123")
print(state) # Outputs: {"status": "active"}
Remember, this is an in-memory store. Do not use it for persistent storage!
__init__(task_id)
¶
💥 Initialize a new in-memory state manager.
get(task_id, key)
¶
📖 Get the state associated with a key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key to get the state for. |
required |
Returns:
Name | Type | Description |
---|---|---|
Dict |
Optional[Dict]
|
The state associated with the key, or None if not found. |