TTL memoization for sync/async functions with stampede protection
Project description
cachememo
Tiny, safe memoization for Python - with TTL and async support.
cachememo helps you cache the results of expensive functions without accidentally shooting yourself in the foot under concurrency.
It’s designed for when:
- you need time-based expiration (TTL)
- you are working with async functions
- you want to avoid cache stampedes under load
Installation
pip install cachememo
Basic Usage
from cachememo import memoize
@memoize(ttl=60)
def expensive(x: int) -> int:
return x * 2
@memoize(ttl=30)
async def fetch_user(uid: str) -> dict:
...
License
MIT
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
cachememo-0.1.1.tar.gz
(5.3 kB
view details)
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 cachememo-0.1.1.tar.gz.
File metadata
- Download URL: cachememo-0.1.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b45c9bcc426e756f4edf69e5dfbdb64715f10948330f439f97e0392991d2ae6
|
|
| MD5 |
105cea47096c22c3f57c9d878d51e646
|
|
| BLAKE2b-256 |
1b094944c492b7c06171363a35d42888feb8f3517bb661ad2309c2b0cfe4e8e1
|
File details
Details for the file cachememo-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cachememo-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dde7fb05d025c7cb7e8489d51700a1334876fa73d14f73bb5ea4bdfa5f901192
|
|
| MD5 |
24b6a93b094aab9f79e5174833092ef1
|
|
| BLAKE2b-256 |
dc5f490794d6447b03bb17730d45748398861682122082b94ce7a320dc64cf1d
|