--- id: flexcache version: "0.3" license: BSD license_treatment: permissive maintenance: dormant --- # flexcache — Saves and loads to the cache a transformed versions of a source object. License: permissive · Maintenance: dormant · Downloads: 5.7M/mo ## What it is and what it does flexcache provides disk-based caching for the results of expensive computations—typically parsing or transformation functions. You define a source object (like a file path) and a converter function (like a parser), then use a DiskCache subclass to load the result; if the cache is fresh, it returns the stored result; if stale or missing, it runs the converter, stores the output, and returns it. The package detects staleness by modification time (DiskCacheByMTime) or by hashing file content (DiskCacheByHash), and stores results as pickled objects with JSON metadata. The core design is extensible: you can subclass DiskCache and mix in header, invalidation, and naming strategies to customize how caching decisions are made. Built-in mixins let you track Python version and platform, validate cache freshness against single or multiple source files, and generate cache filenames from paths, file content, or arbitrary pickled objects. This flexibility makes it suitable for scenarios beyond simple file parsing—any source-to-converted-object transformation where you want persistent, invalidation-aware caching. Use it for: - Cache parsed configuration or data files to avoid re-parsing on every application startup - Speed up build pipelines by caching the output of expensive transformations and detecting source changes - Store computed results of scientific calculations and reuse them when input files haven't changed - Implement a persistent memoization layer for functions that process files or large datasets ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Caches the results of expensive computations to disk, automatically detecting when source files change and invalidating stale cached data based on file modification time or content hash. Yes, if you need simple disk-based caching with automatic invalidation and can tolerate dormant maintenance. The package is stable (no known vulnerabilities, low install friction, permissive license) and solves a real problem—avoiding recomputation when source files haven't changed. However, expect no active bug fixes or compatibility updates; evaluate whether your project's stability requirements align with that trade-off. ## Install pip install flexcache uv add flexcache poetry add flexcache ## Installing flexcache Before you install: Low friction to install; dormant maintenance status (last commit 2024-11-09, no releases for 888 days) means bug fixes and compatibility updates are unlikely, though the package remains functional. License in practice: BSD license is permissive; you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: from flexcache import DiskCacheByMTime def parse(path): with open(path) as f: return f.read() dc = DiskCacheByMTime(cache_folder="/tmp/cache") content, basename = dc.load("source.txt", converter=parse) Requires Python >= 3.9; source objects and converters must be picklable for storage. Verify before relying: - Whether the package handles concurrent access safely or requires external locking - Performance characteristics when cache folder contains many files - Compatibility with Python versions beyond 3.11 given the long release dormancy ## Package facts - License: BSD (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 5.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags disk caching for expensive functions, persistent result caching, file-based cache invalidation, mtime-based cache, hash-based cache detection, caching, memoization, file-based-storage [View on SkillFed](https://skillfed.io/packages/flexcache) · [View on PyPI](https://pypi.org/project/flexcache/)