cache: Evaluate expression and cache, or load from cache

View source: R/cache.r

cacheR Documentation

Evaluate expression and cache, or load from cache

Description

If the file exists, the expression is not evaluated – the cached result is returned. If the file path does not exist, the expression is evaluated and stored as a parquet file at the location specified by the path. To trigger a re-run, delete the file.

Usage

cache(expr, path)

Arguments

expr

An R expression that returns a data.frame-compatible object; see ⁠[arrow::write_parquet()]⁠

path

A file path (where to save/load the object)

Examples

tmp <- tempfile()
cache(Ex1.1(N=10), tmp)  # saves to cache (slow)
cache(Ex1.1(N=10), tmp)  # loads from cache (fast)

pbreheny/hdrm documentation built on March 29, 2025, 5:18 a.m.