Skip to main content

Helpers to use cachetools with async code.

Project description

Helpers to use cachetools with asyncio.

Latest PyPI version https://travis-ci.org/hephex/asyncache.svg?branch=master https://coveralls.io/repos/github/hephex/asyncache/badge.svg?branch=master https://img.shields.io/badge/code%20style-black-000000.svg

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

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.3.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

asyncache-0.3.1-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page