Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -30,12 +30,14 @@ log = getLogger(__name__)
|
|||
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
|
||||
@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:
|
||||
if args in cache:
|
||||
log.debug(f"using result in cache for {args}")
|
||||
|
|
@ -49,5 +51,7 @@ def async_lru(maxsize: Optional[int] = 50) -> Callable:
|
|||
value = cache.popitem(False)
|
||||
log.debug(f"Removing LRU value: {value}")
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
|
|
|||
Loading…
Reference in a new issue