DiskCache

DiskCache(seed: str | int)

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.

Parameters:
NameDescription
seedA seed or namespace for the cache.

This is used to create a unique storage location for the cache data.

Type: str | int

Instance Methods

close

close(self) -> None

Close the cache.

Perform any necessary cleanup, such as closing file handles or releasing resources.