AbstractCache - AG2
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: optionalDEFAULT: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
<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<br>37<br> |
<br>def get(self, key: str, default: Optional[Any] = None) -> Optional[Any]:<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. TYPE: str |
value |
The value to be stored in the cache. TYPE: Any |
Source code in autogen/cache/abstract_cache_base.py
<br>39<br>40<br>41<br>42<br>43<br>44<br>45<br>46<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>48<br>49<br>50<br>51<br>52<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> |