autogen.cache.disk_cache.DiskCache
DiskCache
Implementation of AbstractCache using the DiskCache library.
This class provides a concrete implementation of the AbstractCache
interface using the diskcache library for caching data on disk.
Attributes:
cache (diskcache.Cache): The DiskCache instance used for caching.
Methods:
init(self, seed): Initializes the DiskCache with the given seed.
get(self, key, default=None): Retrieves an item from the cache.
set(self, key, value): Sets an item in the cache.
close(self): Closes the cache.
enter(self): Context management entry.
exit(self, exc_type, exc_value, traceback): Context management exit.
Initialize the DiskCache instance.
Name | Description |
---|---|
seed | Type: str | int |
Instance Methods
close
Close the cache.
Perform any necessary cleanup, such as closing file handles or
releasing resources.
get
Retrieve an item from the cache.
Name | Description |
---|---|
key | The key identifying the item in the cache. Type: str |
default | The default value to return if the key is not found. Defaults to None. Type: Any | None Default: None |
Type | Description |
---|---|
Any | None | The value associated with the key if found, else the default value. |
set
Set an item in the cache.
Name | Description |
---|---|
key | The key under which the item is to be stored. Type: str |
value | The value to be stored in the cache. Type: Any |