aiomemoizettl

Memoize asyncio Python calls with a per-result TTL
Installation
pip install aiomemoizettl
Usage
For a coroutine whose arguments are hashable, you can create a memoized version by passing it to memoize_ttl, along with a function that converts its return value to a TTL.
For example, the below
import asyncio
from aiomemoizettl import memoize_ttl
async def main():
memoized = memoize_ttl(coro, get_ttl=lambda result: result['ttl'])
results = await asyncio.gather(*[
memoized(1),
memoized(2),
])
await asyncio.sleep(1)
results = await asyncio.gather(*[
memoized(1),
memoized(2), # Will used the cached value of `coro(2)`
])
async def coro(value):
print('Inside coro', value)
return {'ttl': value, 'some-other': 'data'}
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
will output
Inside coro 1
Inside coro 2
Inside coro 1
Metadata
Release files for aiomemoizettl 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiomemoizettl-0.0.3.tar.gz | 2.1 kB | Without provenance | Details for aiomemoizettl-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiomemoizettl-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for aiomemoizettl-0.0.3-py3-none-any.whl |
Total release size: 5.2 kB
Release files / aiomemoizettl-0.0.3.tar.gz
| Download URL | aiomemoizettl-0.0.3.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a80d2dc765e545263f515363b6700ec8cf86fa3968b529f56390b28e34f743d
|
|
BLAKE2b-256 checksum How to use checksums |
3f6de57e96f11ee334ec746b4d7a96351b35f6b42e53855c2a7c255d16be62e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Release files / aiomemoizettl-0.0.3-py3-none-any.whl
| Download URL | aiomemoizettl-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07a6becac60f6cd2604b9f2b73bcd9a50079a0b7b55e2a4e45b1eec5a3ea9659
|
|
BLAKE2b-256 checksum How to use checksums |
364959ad30138158b09ee058c72d053461c15dcc3f43fe26f53fed98aab3c32e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Security for aiomemoizettl 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.