skillfed

cachetools-async

Provides decorators that are inspired by and work closely with cachetools' for caching asyncio functions and methods.

cachetools-async v0.0.5 512.7K downloads/30d#6,255 on PyPI18
Permissive license MIT Active released

What it is and what it does

cachetools_async adds memoization decorators for asyncio coroutine functions, building on top of cachetools' cache implementations. It lets you decorate async functions with @cached to automatically store and reuse their results, using the same cache strategies (LRU, TTL, etc.) that cachetools provides for synchronous code. The cache itself is not asynchronous—it's a regular mutable mapping—but the decorator handles the async execution model correctly.

A key behavior: if multiple concurrent calls arrive for the same cached key before the first one completes, they all wait for that single result rather than each triggering a separate computation. This deduplication happens transparently, making it useful for scenarios like parallel requests for the same resource.

Use it for:

  • Cache results from async HTTP requests (e.g., weather data, API responses) with TTL to avoid redundant network calls.
  • Deduplicate concurrent async function calls in parallel workloads where multiple tasks request the same expensive computation.
  • Implement LRU caching for async database queries or I/O operations to limit memory and improve response times.
  • Add memoization to async data-fetching functions in web frameworks or async services without rewriting cache logic.
  • Combine with cachetools' cache strategies to apply size limits and eviction policies to async coroutine results.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides async-aware memoization decorators for Python asyncio coroutines, extending cachetools with support for caching async function results using LRU, TTL, and other fixed-size cache strategies.

Yes. Low install friction, active maintenance, no known vulnerabilities, and MIT licensing make it a straightforward choice. Install it if you need memoization for asyncio functions and want to reuse cachetools' familiar cache strategies. The single cachetools dependency is lightweight and widely used.

Install

cachetools-async on PyPI

pip

pip install cachetools-async

uv

uv add cachetools-async

poetry

poetry add cachetools-async

Installing cachetools-async

Before you install

Low friction: pure Python wheel with a single runtime dependency on cachetools. Actively maintained with recent releases; repository is not archived and receives commits.

License in practice

MIT license is permissive and imposes no significant restrictions on use, modification, or distribution in most contexts.

Quickstart

pip install cachetools_async

from cachetools import LRUCache
from cachetools_async import cached

@cached(cache=LRUCache(maxsize=32))
async def fetch_data(key):
    # async work here
    return result

await fetch_data(key)

Requires Python 3.9 or later.

Verify before relying

  • Whether concurrent calls to the same cached async function with different arguments are deduplicated or only identical calls are coalesced.
  • Performance characteristics and memory overhead compared to direct cachetools usage in async contexts.
  • Thread-safety guarantees when the same cached function is called from multiple asyncio tasks or event loops.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — cachetools
Maintenance actively maintained — 431 days since the last release
Last repo commit
First released
Downloads 512,688/month — #6,255 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cachetools_async-0.0.5-py3-none-any.whl

Tags

async function cachingasyncio memoization decoratorcache async coroutinescachetools async supportasync result memoizationTTL cache for async functionsLRU cache asyncio
asynciocachingmemoization

More Software Development packages