cache
cache.cache_factory
CacheFactory
cache_factory
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.
Arguments:
seed
Union[str, int] - Used as a seed or namespace for the cache.redis_url
Optional[str] - URL for the Redis server.cache_path_root
str - Root path for the disk cache.cosmosdb_config
Optional[Dict[str, str]] - Dictionary containing ‘connection_string’, ‘database_id’, and ‘container_id’ for Cosmos DB cache.
Returns:
An instance of RedisCache, DiskCache, or CosmosDBCache.
Examples:
Creating a Redis cache
Creating a Disk cache
Creating a Cosmos DB cache: