--- id: async-cache version: "2.0.3" license: MIT license_treatment: permissive maintenance: active --- # async-cache — an asyncio application layer cache and dataloader for python based microservices and applications with thundering herd protection License: permissive · Maintenance: active · Downloads: 218.1K/mo ## 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 above — 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 pip install async-cache uv add async-cache poetry add async-cache ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 218.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags async cache python, asyncio caching library, thundering herd protection, dataloader batching, ttl cache async, lru cache asyncio, concurrent request deduplication, asyncio, performance-optimization, microservices [View on SkillFed](https://skillfed.io/packages/async-cache) · [View on PyPI](https://pypi.org/project/async-cache/)