cashews
cache tools with async power
What it is and what it does
Cashews is an async-first caching library that wraps multiple storage backends (in-memory, Redis, DiskCache) under a unified decorator and function-call API. It lets you cache async function results with configurable TTL, custom key templates, and cache invalidation strategies—useful for reducing load on slow operations or external services in async applications.
The library emphasizes ease of use through decorators and supports advanced techniques like client-side caching (claimed to be faster than simple Redis caching), bloom filters, compression, and transactional modes. You can mix backends by prefix, serialize complex objects with pickle or dill, and monitor cache hits/misses. It has no required runtime dependencies, making installation lightweight; optional extras unlock Redis, DiskCache, and serialization features.
Use it for:
- Decorate long-running async functions to cache results with automatic TTL expiry and key templating.
- Set up multi-tier caching (in-memory + Redis) by prefix to balance speed and shared state.
- Cache database query results or API responses in async web frameworks like FastAPI.
- Implement cache invalidation by tags or time-based strategies to keep stale data out.
- Use client-side caching with Redis to reduce round-trips and improve latency in high-throughput services.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Async cache framework with decorator and direct API support for in-memory, Redis, and DiskCache backends, including TTL management, cache invalidation, and optional client-side caching.
Yes. Cashews is production-ready (stable classifier, active maintenance, no known vulnerabilities), has low install friction, and offers a clean async API with flexible backends. Choose it if you need decorator-based caching in async code and want to avoid vendor lock-in to a single backend. The optional extras (Redis, DiskCache) let you start simple and scale later.
Install
cashews on PyPI
pip
pip install cashewsuv
uv add cashewspoetry
poetry add cashewsInstalling cashews
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent release (165 days ago) and 590 repository stars. Supports Python 3.10–3.14.
License in practice
MIT license (permissive) allows commercial and private use with minimal restrictions.
Quickstart
pip install cashews
from cashews import cache
await cache.setup("mem://")
@cache(ttl="3h", key="user:{request.user.uid}")
async def long_running_function(request):
return result
Requires Python 3.10 or later. Optional backends (Redis, DiskCache, dill, xxhash) require separate package installation.
Verify before relying
- Performance claim ('2x faster than aiocache') lacks benchmark details or methodology.
- Actual memory footprint and scalability limits for in-memory backend with large datasets.
- Transactionality semantics and guarantees across different backends.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 165 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 755,176/month — #5,141 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cashews-7.5.0-py3-none-any.whl
Keywords: cache, aio, async, multicache, aiocache
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
aiocacheProvides asyncio-compatible caching with…
unclear · top 5,000 on PyPI
python-redis-cacheDecorator-based caching for Python functions…
permissive · top 15,000 on PyPI
async-cacheIn-memory async cache for Python applications…
permissive · top 15,000 on PyPI
fastapi-cache2Caches FastAPI endpoint and function results…
permissive · top 5,000 on PyPI
cachelibCacheLib provides a unified API for interacting…
permissive · top 5,000 on PyPI
django-redisProvides a Redis cache and session backend for…
permissive · top 5,000 on PyPI
flexcacheCaches the results of expensive computations to…
permissive · top 5,000 on PyPI
diskcache-weaveDisk-backed cache library that stores key-value…
permissive · top 15,000 on PyPI
diskcache-stubsProvides type hints and stubs for the diskcache…
permissive · top 15,000 on PyPI
diskcacheDiskCache provides a pure-Python disk-backed…
permissive · top 1,000 on PyPI