Returns a decorator (for use with %@%) that wraps a function with
disk-backed memoization.
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.
- track_env
Logical; if
TRUE(default), recursively hash the user-defined helper functions and globals reachable fromfvia.get_scoped_env_hash(). Set toFALSEto disable the scoped-env walk entirely — the cache key then depends only on the wrapped function's body, arguments, packages, and explicit dependencies. Useful for orchestrator functions with deep dependency trees where the recursive walk is slow or where you prefer to declare deps explicitly viadepends_on_files/depends_on_vars. Overridable session-wide withoptions(cacheR.track_env = FALSE).