Skip to contents

Returns a decorator (for use with %@%) that wraps a function with disk-backed memoization.

Usage

cacheFile(
  cache_dir = NULL,
  backend = getOption("cacheR.backend", "rds"),
  ignore_args = NULL,
  file_pattern = NULL,
  env_vars = NULL,
  hash_file_paths = TRUE,
  algo = "xxhash64",
  version = NULL,
  depends_on_files = NULL,
  depends_on_vars = NULL
)

Arguments

cache_dir

Character path to the cache directory. Defaults to cacheR_default_dir().

backend

Character string selecting the serialization backend, either "rds" or "qs2".

ignore_args

Character vector of argument names to exclude from the cache key.

file_pattern

Optional regex pattern used to filter files when hashing directory contents.

env_vars

Character vector of environment variable names to include in the cache key.

hash_file_paths

Logical; if TRUE (default), file path arguments are normalised and their content hashed as part of the cache key.

algo

Character string specifying the hashing algorithm passed to digest. Default "xxhash64".

version

Optional version tag appended to the cache key so that cached results can be manually invalidated.

depends_on_files

Character vector of file paths whose content should be included in the cache key.

depends_on_vars

Character vector of global variable names whose values should be included in the cache key.

Value

A decorator function suitable for use with %@%.