Description
This is cache for coroutines with a ttl parameter and the auto_refresh functional.
Explanation
auto_refreshparameter is needs to call is cached coroutine again
It have been make for coroutines what getting a large data volume from third-party heavy APIs, information from which may change periodically.
Installation
pip install coroutincache
Usage
Simple usage:
import asyncio
from fastapi import FastAPI
from coroutincache import asyncache
from LogSettings import get_logger
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
Like regular cache with ttl parameter
import asyncio
from coroutincache import asyncache
@asyncache(ttl=20, auto_refresh=False)
async def load_from_api(params=None):
await asyncio.sleep(3)
return [{'namespace': 'A1'}, {'namespace': 'A2'}, {'namespace': 'A3'}] # Large data
License
This project is licensed under the MIT License - see the MIT LICENSE file for details.
Metadata
Release files for coroutincache 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coroutincache-1.5.0.tar.gz | 3.1 kB | Without provenance | Details for coroutincache-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coroutincache-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for coroutincache-1.5.0-py3-none-any.whl |
Total release size: 7.1 kB
Release files / coroutincache-1.5.0.tar.gz
| Download URL | coroutincache-1.5.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c91173666ca5e81d581c45aeb9b48aa5f1148f062b6518c8956cb57e036a3380
|
|
BLAKE2b-256 checksum How to use checksums |
320c90172c00ca9764b44098505a001554fca8c3013e2c90db6cb3d6de28cc20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.7 Windows/10
|
Release files / coroutincache-1.5.0-py3-none-any.whl
| Download URL | coroutincache-1.5.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
929ce0b4654f7abbb466262dd4d9699fb629bfcedabba4bf9e93a6548df61c52
|
|
BLAKE2b-256 checksum How to use checksums |
4b3809efed0f2059755b08f99f148ffaa3d8bb66b77d3f2bccbc19b91216b00a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.7 Windows/10
|
Security for coroutincache 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.