cache_method: Create a cached function for CellBench

Description Usage Arguments Details Value See Also Examples

View source: R/memoise.R

Description

Take a function and return a cached version. The arguments and results of a cached method is saved to disk and if the cached function is called again with the same arguments then the results will be retrieved from the cache rather than be recomputed.

Usage

1
cache_method(f, cache = getOption("CellBench.cache"))

Arguments

f

the function to be cached

cache

the cache information (from memoise package)

Details

(CAUTION) Because cached functions called with the same argument will always return the same output, pseudo-random methods will not return varying results over repeated runs as one might expect.

This function is a thin wrapper around memoise

Value

function whose results are cached and is called identically to f

See Also

set_cellbench_cache_path

Examples

1
2
3
4
# sets cache path to a temporary directory
set_cellbench_cache_path(file.path(tempdir(), ".CellBenchCache"))
f <- function(x) { x + 1 }
cached_f <- cache_method(f)

CellBench documentation built on Nov. 8, 2020, 5:11 p.m.