Framework for Python

Caching

cache()

Store a value in the cache and return it.

Usage

cache(
    name: str,
    value: T,
    file: str | Path | None = None,
    expire_after: float | str | None = None,
) -> T

Arguments

Name Type Default Description
name required str

The cache name.

value required T

The value. DataFrames are stored as Parquet, anything else with pickle.

file str | Path | None None

Store the value in this file instead of the cache folder.

expire_after float | str | None None

Hours until the value expires, or a string like "2 days". Default: options.data.cache_default_expire in the settings, else never.