# 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.<br>**TYPE:**`str` |
| `default` | The default value to return if the key is not found. Defaults to None.<br>**TYPE:**`optional`**DEFAULT:**`None` |

| RETURNS | DESCRIPTION |
| --- | --- |
| `Any | None` | The value associated with the key if found, else the default value. |

Source code in `autogen/cache/abstract_cache_base.py`

|     |     |
| --- | --- |
| ```<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>``` | ```<br>def get(self, key: str, default: Any | None = None) -> Any | None:<br>    """Retrieve an item from the cache.<br>    Args:<br>        key (str): The key identifying the item in the cache.<br>        default (optional): The default value to return if the key is not found.<br>                            Defaults to None.<br>    Returns:<br>        The value associated with the key if found, else the default value.<br>    """<br>    ...<br>``` |

### `set`

```
set(key, value)
```

Set an item in the cache.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `key` | The key under which the item is to be stored.<br>**TYPE:**`str` |
| `value` | The value to be stored in the cache.<br>**TYPE:**`Any` |

Source code in `autogen/cache/abstract_cache_base.py`

|     |     |
| --- | --- |
| ```<br>35<br>36<br>37<br>38<br>39<br>40<br>41<br>42<br>``` | ```<br>def set(self, key: str, value: Any) -> None:<br>    """Set an item in the cache.<br>    Args:<br>        key (str): The key under which the item is to be stored.<br>        value: The value to be stored in the cache.<br>    """<br>    ...<br>``` |

### `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`

|     |     |
| --- | --- |
| ```<br>44<br>45<br>46<br>47<br>48<br>``` | ```<br>def close(self) -> None:<br>    """Close the cache. Perform any necessary cleanup, such as closing network connections or<br>    releasing resources.<br>    """<br>    ...<br>``` |
