with_cache: Cache and load an R object from disk

View source: R/caching.R

with_cacheR Documentation

Cache and load an R object from disk

Description

If the target file exists it will be loaded unless the 'overwrite' argument is set.

Usage

with_cache(file, object, overwrite = FALSE, ...)

Arguments

file

Where to cache the R object

object

An R object

overwrite

Whether to overwrite the cached object

...

Unused, will warn

Value

The fresh/cached object.

Examples

## Not run: 
target <- tempfile()
result <- with_cache(target, { 1 + 1 })
result <- with_cache(target, { 1 + 1 })
unlink(target)

## End(Not run)

tomshafer/tshfr documentation built on Sept. 27, 2022, 2:42 p.m.