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.2.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.2.tar.gz.
File metadata
- Download URL: cachememo-0.1.2.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 |
40a7f69913b961bb500b46f35c248d4132520005e7bce5a1d4f756285e202cf8
|
|
| MD5 |
3708ddeafd76b8012c781954c371d012
|
|
| BLAKE2b-256 |
44012a6dc6bb6869de0fe5e0b3fe4fe0076fad761081627156e22d73b7dd6373
|
File details
Details for the file cachememo-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cachememo-0.1.2-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 |
8172425abe74a640ce7586997c2d773f30050ddc4e8f33ce17092600b8295fbd
|
|
| MD5 |
ce9f2ccb4a4a8ee45b8851549153fc78
|
|
| BLAKE2b-256 |
841d071550c664b8f9424748160e8dbf1464561cd71b8c8492aef97a34d125fe
|