17 lines
303 B
Python
Raw Normal View History

2025-01-24 16:09:10 +01:00
import functools
cache = functools.cache
def async_cache(func):
cache = {}
@functools.wraps(func)
async def wrapper(*args):
if args in cache:
return cache[args]
result = await func(*args)
cache[args] = result
return result
return wrapper