tools (common/async_utils): set default maxsize to 50 in async_lru

This commit is contained in:
Goffi 2022-10-15 20:37:00 +02:00
commit 7f0e230af4

View file

@ -27,8 +27,13 @@ from sat.core.log import getLogger
log = getLogger(__name__)
def async_lru(maxsize: Optional[int] = None) -> Callable:
"""Decorator to cache async function results using LRU algorithm"""
def async_lru(maxsize: Optional[int] = 50) -> Callable:
"""Decorator to cache async function results using LRU algorithm
@param maxsize: maximum number of items to keep in cache.
None to have no limit
"""
def decorator(func: Callable) -> Callable:
cache = OrderedDict()
async def wrapper(*args) -> Awaitable: