imf_reader.cache.dataframe

DataFrameCache decorator for disk-backed persistent caching of function results.

Wraps a function to cache its return value under <root>/<sublayer>/. DataFrame results are stored as parquet; everything else as pickle. The wrapped function exposes .cache_clear() (zero-arg, returns None) and allows arbitrary attribute assignment on the wrapper (e.g. fetch_data.last_version_fetched = …).

Attributes

logger

Functions

dataframe_cache(→ Any)

Decorator factory that caches a function's return value to disk.

Module Contents

imf_reader.cache.dataframe.logger
imf_reader.cache.dataframe.dataframe_cache(*, ttl: datetime.timedelta, sublayer: str) Any

Decorator factory that caches a function’s return value to disk.

Parameters:
  • ttl – How long cached results are valid.

  • sublayer – Subdirectory under the cache root (e.g. “weo_api”, “sdr”).

Returns:

Decorator that wraps the target function.