cache: cache an object

View source: R/cache.R

cacheR Documentation

cache an object

Description

cache an R object

Usage

cache(name, expr, overwrite = FALSE, time = 3600, env = parent.frame())

Arguments

name

Name of the object

expr

Expression to evaluate

overwrite

If 'TRUE' saved over current objects

time

Either time (seconds) for how long to cache the object(s) or the time as a 'POSIXt' object

env

Environment to load object into if found

Value

Result of 'expr', or cached result

Examples

res <- .POSIXct(0)
for (i in 1:6) {
  cache("foo", Sys.time(), time = 1)
  Sys.sleep(0.5)
  res[i] <- foo
}
res

jmbarbone/jordanExtra documentation built on Aug. 4, 2023, 5:37 p.m.