autogen_ext.cache_store.diskcache#

class DiskCacheStore(cache_instance: Cache)[source]#

Bases: CacheStore[T], Component[DiskCacheStoreConfig]

A typed CacheStore implementation that uses diskcache as the underlying storage. See ChatCompletionCache for an example of usage.

Parameters:

cache_instance – An instance of diskcache.Cache. The user is responsible for managing the DiskCache instance’s lifetime.

classmethod _from_config(config: DiskCacheStoreConfig) Self[source]#

Create a new instance of the component from a configuration object.

Parameters:

config (T) – The configuration object.

Returns:

Self – The new instance of the component.

_to_config() DiskCacheStoreConfig[source]#

Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance.

Returns:

T – The configuration of the component.

component_config_schema#

alias of DiskCacheStoreConfig

component_provider_override: ClassVar[str | None] = 'autogen_ext.cache_store.diskcache.DiskCacheStore'#

Override the provider string for the component. This should be used to prevent internal module names being a part of the module name.

get(key: str, default: T | None = None) T | None[source]#

Retrieve an item from the store.

Parameters:
  • key – The key identifying the item in the store.

  • default (optional) – The default value to return if the key is not found. Defaults to None.

Returns:

The value associated with the key if found, else the default value.

set(key: str, value: T) None[source]#

Set an item in the store.

Parameters:
  • key – The key under which the item is to be stored.

  • value – The value to be stored in the store.

pydantic model DiskCacheStoreConfig[source]#

Bases: BaseModel

Configuration for DiskCacheStore

Show JSON schema
{
   "title": "DiskCacheStoreConfig",
   "description": "Configuration for DiskCacheStore",
   "type": "object",
   "properties": {
      "directory": {
         "title": "Directory",
         "type": "string"
      }
   },
   "required": [
      "directory"
   ]
}

Fields:
field directory: str [Required]#