This can be used by a user to pre-test their arguments before running Cache, for example to determine whether there is a cached copy.

CacheDigest(
  objsToDigest,
  ...,
  algo = "xxhash64",
  calledFrom = "CacheDigest",
  .functionName = NULL,
  quick = FALSE
)

Arguments

objsToDigest

A list of all the objects (e.g., arguments) to be digested

...

passed to .robustDigest.

algo

The digest algorithm to use. Default xxhash64 (see digest::digest() for others).

calledFrom

a Character string, length 1, with the function to compare with. Default is "Cache". All other values may not produce robust CacheDigest results.

.functionName

A an arbitrary character string that provides a name that is different than the actual function name (e.g., "rnorm") which will be used for messaging. This can be useful when the actual function is not helpful for a user, such as do.call.

quick

Logical or character. If TRUE, no disk-based information will be assessed, i.e., only memory content. See Details section about quick in Cache().

Value

A list of length 2 with the outputHash, which is the digest that Cache uses for cacheId and also preDigest, which is the digest of each sub-element in objsToDigest.

Examples

data.table::setDTthreads(2)
a <- Cache(rnorm, 1)
#> No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
#>   this will not persist across R sessions.
#> Saved! Cache file: ca275879d5116967.rds; fn: rnorm

# like with Cache, user can pass function and args in a few ways
CacheDigest(rnorm(1)) # shows same cacheId as previous line
#> $outputHash
#> [1] "ca275879d5116967"
#> 
#> $preDigest
#> $preDigest$.FUN
#> [1] "4f604aa46882b368"
#> 
#> $preDigest$mean
#> [1] "c40c00762a0dac94"
#> 
#> $preDigest$n
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$sd
#> [1] "853b1797f54b229c"
#> 
#> 
CacheDigest(rnorm, 1) # shows same cacheId as previous line
#> $outputHash
#> [1] "ca275879d5116967"
#> 
#> $preDigest
#> $preDigest$.FUN
#> [1] "4f604aa46882b368"
#> 
#> $preDigest$mean
#> [1] "c40c00762a0dac94"
#> 
#> $preDigest$n
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$sd
#> [1] "853b1797f54b229c"
#> 
#>