The Simple library for corutine cache
Project description
Description
This is simple cache for corutines with a ttl parameter.
It have been make for corutines what getting a large data volume for over external api request.
Installation
pip install coroutincache
Simple usage:
import asyncio
from fastapi import FastAPI
from LogSettings import get_logger
from coroutincache import asyncache
logger = get_logger('consolemode')
app = FastAPI()
@asyncache(ttl=20)
async def load_from_api(params=None):
await asyncio.sleep(3)
logger.debug(f'LOAD FROM API')
return [{'namespace': 'A1'}, {'namespace': 'A2'}, {'namespace': 'A3'}]
@app.get("/")
async def root():
result = await load_from_api(32)
logger.info(f'Result: {result}')
return result
License
This project is licensed under the MIT License - see the MIT LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
coroutincache-1.3.1.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for coroutincache-1.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4a4519f1d7cd899d85af06e193a40448521c44791d2dd57c5a9b7cb5de85280 |
|
MD5 | 55e7f2d743cd1a21e735844bd45f3a01 |
|
BLAKE2b-256 | 30dc2143dac4bfddca39e7649a29f3fe0e6daf44fb24891b526d0f910e289564 |