asyncache ========= .. py:module:: asyncache .. autoapi-nested-parse:: Helpers to use [cachetools](https://github.com/tkem/cachetools) with asyncio. This implementation is a fork of the original asyncache implementation by hephex which is licensed under the included MIT License. The original implementation became unmaintained and ran into dependency resolution issues. Vendoring in this tiny wrapper allows us to depend on cachetools directly. See https://github.com/kr8s-org/kr8s/issues/681 for more details. If the cachetools package gets support for asyncio then we can remove these helpers and use cachetools directly. See https://github.com/tkem/cachetools/issues/222 for status on this. Functions --------- .. autoapisummary:: asyncache.cached Package Contents ---------------- .. py:function:: cached(cache: Optional[collections.abc.MutableMapping[_KT, Any]], key: Callable[Ellipsis, _KT] = keys.hashkey, lock: Optional[AbstractContextManager[Any]] = None) -> IdentityFunction Decorator to wrap a function or a coroutine with a memoizing callable that saves results in a cache. When ``lock`` is provided for a standard function, it's expected to implement ``__enter__`` and ``__exit__`` that will be used to lock the cache when gets updated. If it wraps a coroutine, ``lock`` must implement ``__aenter__`` and ``__aexit__``.