asyncache¶
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¶
|
Decorator to wrap a function or a coroutine with a memoizing callable |
Package Contents¶
- asyncache.cached(cache: collections.abc.MutableMapping[_KT, Any] | None, key: Callable[Ellipsis, _KT] = keys.hashkey, lock: AbstractContextManager[Any] | None = None) IdentityFunction¶
Decorator to wrap a function or a coroutine with a memoizing callable that saves results in a cache.
When
lockis 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,lockmust implement__aenter__and__aexit__.