A blazing-fast, async-friendly, thread-safe caching decorator for Python that just works. Drop it on any function and watch it remember results like magic.
Project description
🥜 remembers
Remember everything. Forget nothing (until you want to).
A blazing-fast, async-friendly, thread-safe caching decorator for Python that just works. Drop it on any function and watch it remember results like magic.
✨ Features
- 🎯 One decorator, zero config - Just
@remember()and you're done - ⚡ Async/await ready - Works seamlessly with sync and async functions
- 🔒 Thread-safe - Battle-tested for concurrent access
- 💾 Optional persistence - Cache survives restarts with disk storage
- ⏱️ TTL support - Auto-expire entries when you want
- 🎨 Smart key building - Cache by specific args or nested paths
- 📊 Built-in stats - Track hits, misses, and hit rates
Quick Start
from remembers import remember
@remember(maxsize=128, ttl_seconds=300)
def expensive_api_call(user_id: int):
# This only runs once per user_id (for 5 minutes)
return fetch_user_data(user_id)
# Works with async too!
@remember(maxsize=64)
async def fetch_weather(city: str):
return await weather_api.get(city)
Advanced Usage
Custom Cache Keys
@remember(key_args=['user.id', 'config.api_key'])
def process_user(user, config):
# Only caches based on user.id and config.api_key
return expensive_processing(user, config)
Persistent Cache
@remember(maxsize=100, persist=True, cache_dir=".cache")
def expensive_computation(x: int):
# Results survive restarts!
return heavy_calculation(x)
Check Cache Stats
@remember(maxsize=50)
def my_function(arg):
return process(arg)
my_function("test")
info = my_function.cache_info()
print(f"Hit rate: {info['hit_rate']:.2%}")
# Hit rate: 85.00%
Installation
pip install remembers
Requirements
- Python 3.12+
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
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 remembers-0.1.0.tar.gz.
File metadata
- Download URL: remembers-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb3d782860e3cf0cb539e2e894dc65432e72191620f08b3ee7aaae23b9935dd5
|
|
| MD5 |
a2764c4817495abde6e7ef7ffdd38561
|
|
| BLAKE2b-256 |
ae769aa7f0e8b1e45a72ec99b2c7148198104ff289d57f881eda7ad2c17a0358
|
File details
Details for the file remembers-0.1.0-py3-none-any.whl.
File metadata
- Download URL: remembers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e885b62361887a18b2aa91d537967dc7988709d378c924fcd97bef2d03278c6
|
|
| MD5 |
c7bbdd4ed95bcfc423a07b880ee18442
|
|
| BLAKE2b-256 |
e86d6d7f7146c7c5c56b7ae8143bc730133004e1eae9a8100033f9d8b2525b22
|