skillfed

async-cache

an asyncio application layer cache and dataloader for python based microservices and applications with thundering herd protection

async-cache v2.0.3 218.1K downloads/30d#9,344 on PyPI106
Permissive license MIT Active released

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-cache

uv

uv add async-cache

poetry

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 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

async cache pythonasyncio caching librarythundering herd protectiondataloader batchingttl cache asynclru cache asyncioconcurrent request deduplication
asyncioperformance-optimizationmicroservices

More Application Frameworks packages