camel.storages.key_value_storages package#
Submodules#
camel.storages.key_value_storages.base module#
- class camel.storages.key_value_storages.base.BaseKeyValueStorage[source]#
Bases:
ABC
An abstract base class for key-value storage systems. Provides a consistent interface for saving, loading, and clearing data records without any loss of information.
An abstract base class designed to serve as a foundation for various key-value storage systems. The class primarily interacts through Python dictionaries.
This class is meant to be inherited by multiple types of key-value storage implementations, including, but not limited to, JSON file storage, NoSQL databases like MongoDB and Redis, as well as in-memory Python dictionaries.
camel.storages.key_value_storages.in_memory module#
- class camel.storages.key_value_storages.in_memory.InMemoryKeyValueStorage[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseKeyValueStorage
using in-memory list. Ideal for temporary storage purposes, as data will be lost when the program ends.
camel.storages.key_value_storages.json module#
- class camel.storages.key_value_storages.json.JsonStorage(path: Path | None = None)[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseKeyValueStorage
using JSON files. Allows for persistent storage of records in a human-readable format.- Parameters:
path (Path, optional) – Path to the desired JSON file. If None, a default path ./chat_history.json will be used. (default:
None
)
camel.storages.key_value_storages.redis module#
- class camel.storages.key_value_storages.redis.RedisStorage(sid: str, url: str = 'redis://localhost:6379', loop: AbstractEventLoop | None = None, **kwargs)[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseCacheStorage
using Redis as the backend. This is suitable for distributed cache systems that require persistence and high availability.- property client: Redis | None#
Returns the Redis client instance.
- Returns:
The Redis client instance.
- Return type:
redis.asyncio.Redis
Module contents#
- class camel.storages.key_value_storages.BaseKeyValueStorage[source]#
Bases:
ABC
An abstract base class for key-value storage systems. Provides a consistent interface for saving, loading, and clearing data records without any loss of information.
An abstract base class designed to serve as a foundation for various key-value storage systems. The class primarily interacts through Python dictionaries.
This class is meant to be inherited by multiple types of key-value storage implementations, including, but not limited to, JSON file storage, NoSQL databases like MongoDB and Redis, as well as in-memory Python dictionaries.
- class camel.storages.key_value_storages.InMemoryKeyValueStorage[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseKeyValueStorage
using in-memory list. Ideal for temporary storage purposes, as data will be lost when the program ends.
- class camel.storages.key_value_storages.JsonStorage(path: Path | None = None)[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseKeyValueStorage
using JSON files. Allows for persistent storage of records in a human-readable format.- Parameters:
path (Path, optional) – Path to the desired JSON file. If None, a default path ./chat_history.json will be used. (default:
None
)
- class camel.storages.key_value_storages.RedisStorage(sid: str, url: str = 'redis://localhost:6379', loop: AbstractEventLoop | None = None, **kwargs)[source]#
Bases:
BaseKeyValueStorage
A concrete implementation of the
BaseCacheStorage
using Redis as the backend. This is suitable for distributed cache systems that require persistence and high availability.- property client: Redis | None#
Returns the Redis client instance.
- Returns:
The Redis client instance.
- Return type:
redis.asyncio.Redis