17 lines
303 B
Python
17 lines
303 B
Python
|
|
||
|
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
|