CacheFactory

CacheFactory()

Static Methods

cache_factory

cache_factory(
    seed: str | int,
    redis_url: str | None = None,
    cache_path_root: str = '.cache',
    cosmosdb_config: dict[str, typing.Any] | None = None
) -> autogen.cache.AbstractCache

Factory function for creating cache instances.

This function decides whether to create a RedisCache, DiskCache, or CosmosDBCache instance based on the provided parameters. If RedisCache is available and a redis_url is provided, a RedisCache instance is created. If connection_string, database_id, and container_id are provided, a CosmosDBCache is created. Otherwise, a DiskCache instance is used.

Parameters:
NameDescription
seedUsed as a seed or namespace for the cache.

Type: str | int
redis_urlURL for the Redis server.

Type: str | None

Default: None
cache_path_rootRoot path for the disk cache.

Type: str

Default: ‘.cache’
cosmosdb_configDictionary containing ‘connection_string’, ‘database_id’, and ‘container_id’ for Cosmos DB cache.

Type: dict[str, typing.Any] | None

Default: None
Returns:
TypeDescription
autogen.cache.AbstractCacheAn instance of RedisCache, DiskCache, or CosmosDBCache.