INNER CODE UNIT · Python
wrapper
kr8s-org/kr8s · kr8s/_vendored/asyncache/__init__.py:147
async def wrapper(self, *args, **kwargs):
method_cache = cache(self)
if method_cache is None:
return await method(self, *args, **kwargs)
k = key(self, *args, **kwargs)
try:
async with lock(self):
return method_cache[k]
except KeyError:
pass # key not found
val = await method(self, *args, **kwargs)
try:
async with lock(self):
method_cache[k] = val