> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.cache.cache_factory.CacheFactory

<h2 id="autogen.cache.cache_factory.CacheFactory" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">CacheFactory</span>
</h2>

```python theme={null}
CacheFactory()
```

### Static Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### cache\_factory

```python theme={null}
cache_factory(
    seed: str | int,
    redis_url: str | None = None,
    cache_path_root: str = '.cache',
    cosmosdb_config: dict[str, Any] | None = None
) -> AbstractCache
```

Factory function for creating cache instances.<br />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.<br />

<b>Parameters:</b>

| Name              | Description                                                                                                                                                                           |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `seed`            | Used as a seed or namespace for the cache.<br /><br />**Type:** str \| int                                                                                                            |
| `redis_url`       | URL for the Redis server.<br /><br />**Type:** str \| None<br /><br />**Default:** None                                                                                               |
| `cache_path_root` | Root path for the disk cache.<br /><br />**Type:** str<br /><br />**Default:** '.cache'                                                                                               |
| `cosmosdb_config` | Dictionary containing 'connection\_string', 'database\_id', and 'container\_id' for Cosmos DB cache.<br /><br />**Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** None |

<b>Returns:</b>

| Type                                                             | Description                                             |
| ---------------------------------------------------------------- | ------------------------------------------------------- |
| [AbstractCache](/docs/api-reference/autogen/cache/AbstractCache) | An instance of RedisCache, DiskCache, or CosmosDBCache. |

<br />
