Caching.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user