Skip to content

AbstractCache

autogen.cache.AbstractCache #

Bases: Protocol

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

get #

get(key, default=None)

Retrieve an item from the cache.

PARAMETER 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: optional DEFAULT: None

RETURNS DESCRIPTION
Optional[Any]

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

Source code in autogen/cache/abstract_cache_base.py
def get(self, key: str, default: Optional[Any] = None) -> Optional[Any]:
    """Retrieve an item from the cache.

    Args:
        key (str): The key identifying the item in the cache.
        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 #

set(key, value)

Set an item in the cache.

PARAMETER 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

Source code in autogen/cache/abstract_cache_base.py
def set(self, key: str, value: Any) -> None:
    """Set an item in the cache.

    Args:
        key (str): The key under which the item is to be stored.
        value: The value to be stored in the cache.
    """
    ...

close #

close()

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

Source code in autogen/cache/abstract_cache_base.py
def close(self) -> None:
    """Close the cache. Perform any necessary cleanup, such as closing network connections or
    releasing resources.
    """
    ...