an asyncio cache
Project description
- info:
A caching solution for asyncio
Installation
pip install async-cache
Basic Usage
# LRU Cache
from cache import AsyncLRU
@AsyncLRU(maxsize=128)
async def func(*args, **kwargs):
"""
maxsize : max number of results that are cached.
if max limit is reached the oldest result is deleted.
"""
pass
# TTL Cache
from cache import AsyncTTL
@AsyncTTL(time_to_live=60, maxsize=1024, skip_args=1)
async def func(*args, **kwargs):
"""
time_to_live : max time for which a cached result is valid (in seconds)
maxsize : max number of results that are cached.
if max limit is reached the oldest result is deleted.
skip_args : Use `1` to skip first arg of func in determining cache key
"""
pass
# Supports primitive as well as non-primitive function parameter.
# Currently TTL & LRU cache is supported.
Advanced Usage
class CustomDataClass:
id: int
value: int
from cache import AsyncLRU
@AsyncLRU(maxsize=128)
async def func(model: "CustomDataClass"):
...
# function logic
...
# async-cache will work even if function parameters are:
# 1. orm objects
# 2. request object
# 3. any other custom object type.
# To refresh the function result use the `use_cache=False` param in the function invocation
func(*args, use_cache=False, **kwargs)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_cache-1.2.1.tar.gz.
File metadata
- Download URL: async_cache-1.2.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
985f29dfa0ce66d9b8bf2071fd9e207a19047b1ce5a980c8c27cdf6d166588d5
|
|
| MD5 |
7070ea689ef5b31b6b3deccc675d2a07
|
|
| BLAKE2b-256 |
fbb857d264f9a9426558d1b62fb14e3c9a4bedb2afd892d50b6e381d1c36ac85
|
Provenance
The following attestation bundles were made for async_cache-1.2.1.tar.gz:
Publisher:
python-publish.yml on iamsinghrajat/async-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_cache-1.2.1.tar.gz -
Subject digest:
985f29dfa0ce66d9b8bf2071fd9e207a19047b1ce5a980c8c27cdf6d166588d5 - Sigstore transparency entry: 846197537
- Sigstore integration time:
-
Permalink:
iamsinghrajat/async-cache@7b9c8faecf5274c10740e787aae525b71a97fbb8 -
Branch / Tag:
refs/tags/1.2.1 - Owner: https://github.com/iamsinghrajat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7b9c8faecf5274c10740e787aae525b71a97fbb8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file async_cache-1.2.1-py3-none-any.whl.
File metadata
- Download URL: async_cache-1.2.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8418c71112e11b5785c5ed99bbae10262b74b3138c39ab18e952a8932557d78
|
|
| MD5 |
034724cdfd0be08ea150418572e66d27
|
|
| BLAKE2b-256 |
819bb881f188e60adc3a8ff8e21075fecde9eb472a79b72125c7c5d32e10f995
|
Provenance
The following attestation bundles were made for async_cache-1.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on iamsinghrajat/async-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_cache-1.2.1-py3-none-any.whl -
Subject digest:
e8418c71112e11b5785c5ed99bbae10262b74b3138c39ab18e952a8932557d78 - Sigstore transparency entry: 846197543
- Sigstore integration time:
-
Permalink:
iamsinghrajat/async-cache@7b9c8faecf5274c10740e787aae525b71a97fbb8 -
Branch / Tag:
refs/tags/1.2.1 - Owner: https://github.com/iamsinghrajat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7b9c8faecf5274c10740e787aae525b71a97fbb8 -
Trigger Event:
release
-
Statement type: