flexcache
Saves and loads to the cache a transformed versions of a source object.
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 on this page — 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
flexcache on PyPI
pip
pip install flexcacheuv
uv add flexcachepoetry
poetry add flexcacheInstalling 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 the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | dormant — 888 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,713,037/month — #2,047 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flexcache-0.3-py3-none-any.whl
Keywords: cache, optimization, storage, disk
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
diskcache-weaveDisk-backed cache library that stores key-value…
permissive · top 15,000 on PyPI
diskcacheDiskCache provides a pure-Python disk-backed…
permissive · top 1,000 on PyPI
cacheyCachey provides intelligent caching for…
permissive · top 15,000 on PyPI
diskcache-stubsProvides type hints and stubs for the diskcache…
permissive · top 15,000 on PyPI
requests-cacheAdds persistent HTTP caching to the requests…
permissive · top 5,000 on PyPI
cashewsAsync cache framework with decorator and direct…
permissive · top 15,000 on PyPI
cache-to-diskA decorator that caches function results to…
permissive · top 15,000 on PyPI
fcachefcache provides a dictionary-like file-based…
permissive · top 5,000 on PyPI
memoizationDecorator-based function result caching with…
permissive · top 5,000 on PyPI
pystowPyStow provides a standardized way to store and…
permissive · top 15,000 on PyPI