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 algorithms to be used; currently available choices are md5, which is also the default, sha1, crc32, sha256, sha512, xxhash32, xxhash64, murmur32, spookyhash, blake3, crc32c, xxh3_64, and xxh3_128.

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: 422bae4ed2f770cc.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] "422bae4ed2f770cc"
#> 
#> $preDigest
#> $preDigest$n
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$mean
#> [1] "c40c00762a0dac94"
#> 
#> $preDigest$sd
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$.FUN
#> [1] "4f604aa46882b368"
#> 
#> 
CacheDigest(rnorm, 1) # shows same cacheId as previous line
#> $outputHash
#> [1] "422bae4ed2f770cc"
#> 
#> $preDigest
#> $preDigest$n
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$mean
#> [1] "c40c00762a0dac94"
#> 
#> $preDigest$sd
#> [1] "853b1797f54b229c"
#> 
#> $preDigest$.FUN
#> [1] "4f604aa46882b368"
#> 
#>