INNER CODE UNIT · Python

decorator

kr8s-org/kr8s · kr8s/_vendored/asyncache/__init__.py:144

    def decorator(method):
        if asyncio.iscoroutinefunction(method):

            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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…