Helpers to use cachetools with async functions
Project description
# asyncache
Helpers to use cachetools with asyncio.
[](https://github.com/ambv/black)
## Example
```python
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.md](LICENSE.md) file for details.
## Acknowledgments
* [cachetools](https://github.com/tkem/cachetools)
Helpers to use cachetools with asyncio.
[](https://github.com/ambv/black)
## Example
```python
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.md](LICENSE.md) file for details.
## Acknowledgments
* [cachetools](https://github.com/tkem/cachetools)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asyncache-0.1.0.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for asyncache-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 622e3324ef4252d0afb5c1f2de15eab455276469c96d06c579a08dd31224a752 |
|
MD5 | 61e5ddc06d961fc767df1e432cbb6197 |
|
BLAKE2b-256 | e888ad334b00bba255777f0fd7d97de912d7514b3e26188cf918b87c51b1841b |