Helpers to use cachetools with asyncio.
Installation
asyncache is available from PyPI and can be installed by running:
pip install asyncache
Example
from asyncache import cached
from cachetools import TTLCache
pool = ...
@cached(TTLCache(1024, 60))
async def get_username(user_id):
rec = await pool.fetchrow(
"""
SELECT
username
FROM
users
WHERE
id = $1
""",
user_id,
)
return rec and rec["username"]
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Release files for asyncache 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncache-0.3.1.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncache-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / asyncache-0.3.1.tar.gz
| Download URL | asyncache-0.3.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a1e60a75668e794657489bdea6540ee7e3259c483517b934670db7600bf5035
|
|
BLAKE2b-256 checksum How to use checksums |
49cf17f8a6b6b97f77b5981fbce1266913e718daaa3467b46f60a785cbaadc29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0b2 CPython/3.10.7 Darwin/21.6.0
|
Release files / asyncache-0.3.1-py3-none-any.whl
| Download URL | asyncache-0.3.1-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef20a1024d265090dd1e0785c961cf98b9c32cc7d9478973dcf25ac1b80011f5
|
|
BLAKE2b-256 checksum How to use checksums |
2f9451927deb4f40872361ec4f5534f68f7a9ce81c4ef20bf5cd765307f4c15d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0b2 CPython/3.10.7 Darwin/21.6.0
|