skillfed

flexcache

Saves and loads to the cache a transformed versions of a source object.

flexcache v0.3 5.7M downloads/30d#2,047 on PyPI7
Permissive license BSD DORMANT released

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 flexcache

uv

uv add flexcache

poetry

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 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: System :: FilesystemsTopic :: Utilities

Tags

disk caching for expensive functionspersistent result cachingfile-based cache invalidationmtime-based cachehash-based cache detection
cachingmemoizationfile-based-storage

More Libraries packages