RedisDb
is a class that implements the Db interface using Redis as the backend storage system. It provides high-performance, distributed storage for agent sessions with support for JSON data types and schema versioning.
Parameter | Type | Default | Description |
---|---|---|---|
redis_client | Optional[Redis] | - | Redis client instance to use. If not provided a new client will be created. |
db_url | Optional[str] | - | Redis connection URL (e.g., "redis://localhost:6379/0" or "rediss://user:pass@host:port/db") |
db_prefix | str | "agno" | Prefix for all Redis keys. |
expire | Optional[int] | - | TTL for Redis keys in seconds. |
session_table | Optional[str] | - | Name of the table to store sessions. |
memory_table | Optional[str] | - | Name of the table to store memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge documents. |
Methods
upsert_sessions
Bulk upsert multiple sessions for improved performance on large datasets.
Parameters:
sessions
(List[Session]): List of sessions to upsertdeserialize
(Optional[bool]): Whether to deserialize the sessions. Defaults toTrue
List[Union[Session, Dict[str, Any]]]
upsert_memories
Bulk upsert multiple memories for improved performance on large datasets.
Parameters:
memories
(List[UserMemory]): List of memories to upsertdeserialize
(Optional[bool]): Whether to deserialize the memories. Defaults toTrue
List[Union[UserMemory, Dict[str, Any]]]