AbstractCache

AbstractCache(*args, **kwargs)

This protocol defines the basic interface for cache operations. Implementing classes should provide concrete implementations for these methods to handle caching mechanisms.

Parameters:
NameDescription
*args
**kwargs

Instance Methods

close

close(self) -> None

Close the cache. Perform any necessary cleanup, such as closing network connections or releasing resources.


get

get(
    self,
    key: str,
    default: Any | None = None
) -> Any | None

Retrieve an item from the cache.

Parameters:
NameDescription
keyThe key identifying the item in the cache.

Type: str
defaultThe default value to return if the key is not found.

Defaults to None.

Type: Any | None

Default: None
Returns:
TypeDescription
Any | NoneThe value associated with the key if found, else the default value.

set

set(
    self,
    key: str,
    value: Any
) -> None

Set an item in the cache.

Parameters:
NameDescription
keyThe key under which the item is to be stored.

Type: str
valueThe value to be stored in the cache.

Type: Any