--- id: py-memoize version: "3.1.1" license: Apache License 2.0 license_treatment: permissive maintenance: dormant --- # py-memoize — Caching library for asynchronous Python applications (both based on asyncio and Tornado) that handles dogpiling properly and provides a configurable & extensible API. License: permissive · Maintenance: dormant · Downloads: 182.6K/mo ## What it is and what it does py-memoize is a caching library designed specifically for asynchronous Python code—both asyncio and Tornado—that solves the cache stampede (dog-piling) problem where multiple concurrent tasks simultaneously miss the cache and flood the underlying resource. It wraps expensive async functions with a decorator to cache and reuse their results, and includes built-in protections against concurrent cache misses. The library is highly configurable: you can tune cache timeouts, key generation strategies, storage backends, eviction policies (least-recently-updated by default), and value post-processing (including optional deep-copy). It supports background cache refreshing with separate update and expiration delays, allowing stale values to be refreshed asynchronously without observable latency. All components are extensible, so you can plug in custom storage, key extraction, or eviction logic. Use it for: - Memoize expensive async API calls or database queries in asyncio services to reduce latency and backend load - Prevent cache stampede in high-concurrency async applications where multiple tasks would otherwise recompute the same result simultaneously - Cache results with tunable background refresh to serve stale data while updating in the background, avoiding request latency spikes - Implement custom cache storage (e.g., Redis, Memcached) by extending the provided storage and serialization interfaces - Decorate Tornado async handlers to cache computed responses across concurrent requests ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Caching library for async Python applications that prevents cache stampede (dog-piling) and provides a configurable, extensible API for memoizing expensive async function calls. Yes, if you are building async Python services and need protection against cache stampede. The library is stable and has no known vulnerabilities, but note that maintenance is dormant (676 days since last release)—verify compatibility with your target Python version and async framework before adopting. For simple in-memory caching in active projects, consider whether the dormancy risk is acceptable. ## Install pip install py-memoize uv add py-memoize poetry add py-memoize ## Installing py-memoize Before you install: Installs with no runtime dependencies. Maintenance is dormant—last release was 676 days ago (2024-10-07), though the repository remains active with 74 stars and no archived status. License in practice: Licensed under Apache License 2.0 (permissive), allowing commercial and private use with minimal restrictions. Quickstart: pip install py-memoize import asyncio from memoize.wrapper import memoize @memoize() async def expensive_computation(): return 'result' asyncio.run(expensive_computation()) Verify before relying: - Whether the dormant maintenance status (676 days since last release) affects compatibility with current Python async ecosystems - Real-world performance impact of deep-copy post-processing on large cached objects - Whether ujson extra dependency improves JSON serialization performance meaningfully ## Package facts - License: Apache License 2.0 (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 182.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio caching decorator, async function memoization, cache stampede prevention, dog-piling proof cache, async result caching, configurable async cache, tornado asyncio cache, asyncio, cache-stampede, memoization [View on SkillFed](https://skillfed.io/packages/py-memoize) · [View on PyPI](https://pypi.org/project/py-memoize/)