dot-runCache: Run function and save cache

.runCacheR Documentation

Run function and save cache

Description

This method saves the function that's being called

Usage

.runCache(
  fun,
  ...,
  seed = NULL,
  baseDir = NULL,
  cachePrefix = "generic_cache",
  cacheDigest = list(),
  showMessage = NULL,
  forceRecalc = FALSE,
  addToHash = NULL
)

## S4 method for signature 'function'
.runCache(
  fun,
  ...,
  seed = NULL,
  baseDir = NULL,
  cachePrefix = "generic_cache",
  cacheDigest = list(),
  showMessage = NULL,
  forceRecalc = FALSE,
  addToHash = NULL
)

Arguments

fun

function call name

...

parameters for function call

seed

when function call is random, this allows to set seed beforehand

baseDir

directory where data is stored

cachePrefix

prefix for file name to be generated from parameters (...)

cacheDigest

cache of the digest for one or more of the parameters

showMessage

show message that data is being retrieved from cache

forceRecalc

force the recalculation of the values

addToHash

something to add to the filename generation

Value

the result of fun(...)

Functions

  • .runCache(`function`): accepts function as first argument and save cache

Examples

# [optional] save cache in a temporary directory
#
glmSparseNet:::.baseDir(tempdir())
glmSparseNet:::.runCache(c, 1, 2, 3, 4)
#
# next three should use the same cache
#  note, the middle call should be a little faster as digest is not
#  calculated
#   for the first argument
glmSparseNet:::.runCache(c, 1, 2, 3, 4)
glmSparseNet:::.runCache(c, a = 1, 2, c = 3, 4)

# Using a local folder
# glmSparseNet:::.runCache(c, 1, 2, 3, 4, baseDir = "runcache")


sysbiomed/glmSparseNet documentation built on Feb. 17, 2024, 1:38 p.m.