--- id: cache-to-disk version: "2.0.0" license: unclear license_treatment: permissive maintenance: dormant --- # cache-to-disk — Local disk caching decorator for python function. License: permissive · Maintenance: dormant · Downloads: 110.6K/mo ## What it is and what it does cache_to_disk is a Python decorator that persists function results to disk as pickled files instead of holding them in memory. It's designed for functions that are expensive to run and produce large return values—cases where in-memory caching would be wasteful. Each cached result is keyed by the function's arguments, so different argument combinations trigger fresh execution. You specify a cache lifetime in days; after that period, the cached file is deleted on the next module import. The package provides three main functions: the @cache_to_disk(n_days) decorator itself, a delete_disk_caches_for_function() utility to manually invalidate a function's cache, and a cache_info() method to inspect hit/miss statistics. It also supports a NoCacheCondition exception to prevent caching in error scenarios while still returning a partial result. Use it for: - Cache expensive data-processing pipelines that return large objects for days at a time. - Avoid re-querying slow external APIs or databases when the same arguments are used within a cache window. - Store intermediate results from long-running computations without consuming RAM. - Manually invalidate cached results when a function's logic changes or external data is updated. - Track cache performance with cache_info() to understand hit rates and identify optimization opportunities. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A decorator that caches function results to disk with pickle serialization and automatic expiration based on a configurable number of days. Yes, if you need simple, argument-aware disk caching for expensive functions and can accept dormant maintenance. The package is permissive-licensed, has no dependencies, and installs easily. However, the last update was in 2021—if you need active support, bug fixes, or compatibility with future Python versions, consider alternatives or be prepared to maintain a fork. ## Install pip install cache-to-disk uv add cache-to-disk poetry add cache-to-disk ## Installing cache-to-disk Before you install: Low install friction with no runtime dependencies. Maintenance is dormant—last release was 2021-12-07 and last commit 2023-12-29, so expect no active support or updates. License in practice: MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install cache-to-disk from cache_to_disk import cache_to_disk @cache_to_disk(3) def my_function(): return [i * j for i in range(10000) for j in range(i)] result = my_function() # Cached for 3 days Verify before relying: - Whether pickle serialization is safe for untrusted function return values or if there are known deserialization risks. - Performance characteristics when caching large objects or handling concurrent access to the same cache files. - Compatibility with modern Python versions beyond what the unspecified python_support indicates. ## Package facts - License: not declared (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 110.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags disk caching decorator, function result caching, pickle cache to file, persistent function cache, auto-expiring cache, local disk cache python, caching, persistence, memoization [View on SkillFed](https://skillfed.io/packages/cache-to-disk) · [View on PyPI](https://pypi.org/project/cache-to-disk/)