All Projects → aio-libs → Async Lru

aio-libs / Async Lru

Licence: mit
Simple lru cache for asyncio

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Async Lru

Aioodbc
aioodbc - is a library for accessing a ODBC databases from the asyncio
Stars: ✭ 206 (-16.94%)
Mutual labels:  asyncio
Nest asyncio
Patch asyncio to allow nested event loops
Stars: ✭ 226 (-8.87%)
Mutual labels:  asyncio
Unicorn Binance Websocket Api
An unofficial Python API to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, jersey, us, tr, jex, dex/chain+testnet) in a easy, fast, flexible, robust and fully-featured way.
Stars: ✭ 232 (-6.45%)
Mutual labels:  asyncio
Create Aio App
The boilerplate for aiohttp. Quick setup for your asynchronous web service.
Stars: ✭ 207 (-16.53%)
Mutual labels:  asyncio
Aioreactive
Async/await reactive tools for Python 3.9+
Stars: ✭ 215 (-13.31%)
Mutual labels:  asyncio
Sanic
Async Python 3.7+ web server/framework | Build fast. Run fast.
Stars: ✭ 15,660 (+6214.52%)
Mutual labels:  asyncio
Fastapi Gino Arq Uvicorn
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
Stars: ✭ 204 (-17.74%)
Mutual labels:  asyncio
Odmantic
Async ODM (Object Document Mapper) for MongoDB based on python type hints
Stars: ✭ 240 (-3.23%)
Mutual labels:  asyncio
Piccolo
A fast, user friendly ORM and query builder which supports asyncio.
Stars: ✭ 219 (-11.69%)
Mutual labels:  asyncio
Pyee
A port of Node.js's EventEmitter to python
Stars: ✭ 236 (-4.84%)
Mutual labels:  asyncio
Python Mocket
a socket mock framework - for all kinds of socket animals, web-clients included
Stars: ✭ 209 (-15.73%)
Mutual labels:  asyncio
Aiofile
Real asynchronous file operations with asyncio support.
Stars: ✭ 214 (-13.71%)
Mutual labels:  asyncio
Lightsocks Python
⚡️一个轻巧的网络混淆代理🌏
Stars: ✭ 235 (-5.24%)
Mutual labels:  asyncio
Aiohttp admin
admin interface for aiohttp application http://aiohttp-admin.readthedocs.io
Stars: ✭ 207 (-16.53%)
Mutual labels:  asyncio
Python Kasa
🏠🤖 Python API for TP-Link Kasa Smarthome products
Stars: ✭ 239 (-3.63%)
Mutual labels:  asyncio
Mode
Python AsyncIO Services
Stars: ✭ 204 (-17.74%)
Mutual labels:  asyncio
Maubot
A plugin-based Matrix bot system.
Stars: ✭ 226 (-8.87%)
Mutual labels:  asyncio
Uvicorn Gunicorn Docker
Docker image with Uvicorn managed by Gunicorn for high-performance web applications in Python 3.6 with performance auto-tuning. Optionally with Alpine Linux.
Stars: ✭ 244 (-1.61%)
Mutual labels:  asyncio
Aioamqp
AMQP implementation using asyncio
Stars: ✭ 244 (-1.61%)
Mutual labels:  asyncio
Tokio
Asyncio event loop written in Rust language
Stars: ✭ 236 (-4.84%)
Mutual labels:  asyncio

async_lru

:info: Simple lru cache for asyncio

.. image:: https://travis-ci.com/aio-libs/async_lru.svg?branch=master :target: https://travis-ci.com/aio-libs/async_lru

.. image:: https://img.shields.io/pypi/v/async_lru.svg :target: https://pypi.python.org/pypi/async_lru

.. image:: https://codecov.io/gh/aio-libs/async_lru/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/async_lru

Installation

.. code-block:: shell

pip install async_lru

Usage

This package is 100% port of Python built-in function functools.lru_cache <https://docs.python.org/3/library/functools.html#functools.lru_cache>_ for asyncio <https://docs.python.org/3/library/asyncio.html>_

.. code-block:: python

import asyncio

import aiohttp
from async_lru import alru_cache


@alru_cache(maxsize=32)
async def get_pep(num):
    resource = 'http://www.python.org/dev/peps/pep-%04d/' % num
    async with aiohttp.ClientSession() as session:
        try:
            async with session.get(resource) as s:
                return await s.read()
        except aiohttp.ClientError:
            return 'Not Found'


async def main():
    for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:
        pep = await get_pep(n)
        print(n, len(pep))

    print(get_pep.cache_info())
    # CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)

    # closing is optional, but highly recommended
    await get_pep.close()


loop = asyncio.get_event_loop()

loop.run_until_complete(main())

loop.close()

Python 3.6+ is required

Thanks

The library was donated by Ocean S.A. <https://ocean.io/>_

Thanks to the company for contribution.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].