Metapackage for sync and asyncio cachetools
Project description
scitrera-ext-cachetools
scitrera-ext-cachetools is a metapackage that combines cachetools and asyncache to make them all conveniently available under a single namespace.
It provides both synchronous and asynchronous caching decorators and various cache implementations (TTL, LRU, LFU, etc.) out of the box.
Installation
pip install scitrera-ext-cachetools
Features
- Unified Access: Import everything you need for caching from one place.
- Sync & Async Support: Includes
cachetoolsfor synchronous code andasyncacheforasyncio. - Conditional Caching: Includes
cached_in_production, a utility to easily disable caching in development environments.
Available Exports
From scitrera_ext_cachetools, you can import:
- Decorators:
cached,cachedmethod,cached_async,cachedmethod_async - Cache Types:
Cache,TTLCache,TLRUCache,LRUCache,FIFOCache,RRCache,LFUCache - Utilities:
keys,cached_in_production
cached_in_production
The only new functionality provided by this package is the cached_in_production decorator. It is a "meta-decorator" designed to make it easy to test code without memoization during development while ensuring it is enabled in production, without requiring code changes.
Caching is enabled by default unless the environment variable DEV_NOCACHE is set to True, 1, yes, or other truthy values (parsed via scitrera-app-framework).
Usage Example
Synchronous Caching
from scitrera_ext_cachetools import cached_in_production, TTLCache, cached
@cached_in_production(cached, cache=TTLCache(maxsize=100, ttl=300))
def get_expensive_data(key):
# This logic will be cached in production,
# but can be bypassed in dev by setting DEV_NOCACHE=1
return ...
Asynchronous Caching
from scitrera_ext_cachetools import cached_in_production, TTLCache, cached_async
@cached_in_production(cached_async, cache=TTLCache(maxsize=100, ttl=300))
async def get_expensive_data_async(key):
return ...
License
This project is licensed under the BSD-3-Clause License.
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
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 scitrera_ext_cachetools-0.0.1.tar.gz.
File metadata
- Download URL: scitrera_ext_cachetools-0.0.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e35e348eba702cbc0f944b23ece43708bddde7859b97b46f52d90e293df0885
|
|
| MD5 |
e6979ca3749a4bdc1454bacc4425af09
|
|
| BLAKE2b-256 |
93b6249591adfc1c44db8efa28285dae57f3efcebf13348b298264d2158564d8
|
Provenance
The following attestation bundles were made for scitrera_ext_cachetools-0.0.1.tar.gz:
Publisher:
publish.yml on scitrera/scitrera-ext-cachetools-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitrera_ext_cachetools-0.0.1.tar.gz -
Subject digest:
6e35e348eba702cbc0f944b23ece43708bddde7859b97b46f52d90e293df0885 - Sigstore transparency entry: 797484359
- Sigstore integration time:
-
Permalink:
scitrera/scitrera-ext-cachetools-python@c4e50b8fa319fe0720fca13d9f05e28777288ad4 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/scitrera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4e50b8fa319fe0720fca13d9f05e28777288ad4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scitrera_ext_cachetools-0.0.1-py3-none-any.whl.
File metadata
- Download URL: scitrera_ext_cachetools-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 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 |
613b00c52112ae52370518ae65a9c8b17bc4a259cb0cede6788a230239f2f36e
|
|
| MD5 |
a2313c1b4f198b0258f2f394f6c1c376
|
|
| BLAKE2b-256 |
b58b13c26077db50823ba2727fbe5d8c19778d4ecc9c40de116bfdbe56d18ae4
|
Provenance
The following attestation bundles were made for scitrera_ext_cachetools-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on scitrera/scitrera-ext-cachetools-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitrera_ext_cachetools-0.0.1-py3-none-any.whl -
Subject digest:
613b00c52112ae52370518ae65a9c8b17bc4a259cb0cede6788a230239f2f36e - Sigstore transparency entry: 797484361
- Sigstore integration time:
-
Permalink:
scitrera/scitrera-ext-cachetools-python@c4e50b8fa319fe0720fca13d9f05e28777288ad4 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/scitrera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4e50b8fa319fe0720fca13d9f05e28777288ad4 -
Trigger Event:
push
-
Statement type: