async-cache
an asyncio application layer cache and dataloader for python based microservices and applications with thundering herd protection
What it is and what it does
async-cache is an in-memory application-layer cache designed for async Python microservices and applications. It stores frequently-accessed data in memory with configurable TTL (time-to-live) and LRU eviction, reducing redundant database or API calls. The core API provides a flexible `AsyncCache` class that accepts loader functions to automatically fetch and cache missing values on demand.
The package addresses two common async scaling problems: thundering herd (where many concurrent requests for the same missing key trigger many identical backend calls) and inefficient batch loading (where individual requests could be grouped into one efficient batch query). It includes decorator convenience wrappers (`AsyncLRU`, `AsyncTTL`) for simpler function-level caching, cache warmup to preload hot keys at startup, and built-in metrics (hits, misses, hit rate) for observability and monitoring integration.
Use it for:
- Reduce database load in microservices by caching user profiles or configuration that multiple requests fetch concurrently.
- Implement DataLoader-style batching to group 100 concurrent user ID lookups into a single batch database query.
- Preload frequently-accessed data (hot keys) at application startup to avoid cold-start cache misses.
- Monitor cache effectiveness with built-in metrics (hit rate, size) for Prometheus or other observability systems.
- Decorate async functions to automatically cache results with TTL without rewriting function logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
In-memory async cache for Python applications with TTL, LRU eviction, thundering herd protection, and DataLoader-style batching to reduce redundant work under concurrent load.
Yes. The package has no runtime dependencies, installs with low friction, is actively maintained, carries no known vulnerabilities, and solves real concurrency problems (thundering herd, batch efficiency) that are difficult to handle correctly in async code. It is a solid choice for microservices and applications that need straightforward in-memory caching with async-aware deduplication.
Install
async-cache on PyPI
pip
pip install async-cacheuv
uv add async-cachepoetry
poetry add async-cacheInstalling async-cache
Before you install
Installs with no runtime dependencies and low friction. Actively maintained with recent releases; last commit 2026-05-28 and 106 repository stars indicate ongoing development.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Quickstart
pip install async-cache
from cache import AsyncCache
cache = AsyncCache(maxsize=1000, default_ttl=300)
async def get_data(key):
return await cache.get(
key,
loader=lambda: db_query(key),
)
Verify before relying
- Whether the 5ms batching window mentioned in examples is configurable or a fixed default.
- Performance characteristics and memory overhead when maxsize approaches capacity.
- Behavior of metrics collection under very high concurrency (thread-safety guarantees).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.3) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 114 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 218,109/month — #9,344 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: async_cache-2.0.3-py3-none-any.whl
Keywords: asyncio, lru, cache, async, ttl, dataloader, cache warmup, thundering herd protection
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
aiodataloaderBatches and caches concurrent data requests in…
permissive · top 5,000 on PyPI
async-lruAn LRU cache decorator for async functions that…
permissive · top 1,000 on PyPI
cashewsAsync cache framework with decorator and direct…
permissive · top 15,000 on PyPI
theineTheine is a high-performance in-memory cache…
permissive · top 15,000 on PyPI
cachettlcachettl provides LRU TTL cache decorators for…
permissive · top 15,000 on PyPI
cacheoutCacheout provides in-memory caching with…
permissive · top 5,000 on PyPI
asyncacheProvides decorator-based caching for async…
permissive · top 5,000 on PyPI
onecacheOneCache provides LRU-based caching decorators…
permissive · top 15,000 on PyPI
cachetools-asyncProvides async-aware memoization decorators for…
permissive · top 15,000 on PyPI
acachecontrolAdds HTTP caching to aiohttp requests by…
permissive · top 15,000 on PyPI