The directory must be visible at the same path to all workers that consume cached file outputs. It must support operating-system file locks and atomic directory renames within the filesystem. Use a cache shared with trusted collaborators: reading an R cache is not a sandbox for untrusted objects.
Usage
shared_cache(
path,
verify = TRUE,
timeout = Inf,
visibility_timeout = 0,
poll_interval = 0.05
)Arguments
- path
Cache directory, independent of any individual targets store.
- verify
Verify the contents of cached output files on each cache hit. Set to
FALSEonly for an externally enforced immutable cache. Record integrity and bundle completeness are checked either way.- timeout
Seconds to wait for another process computing the same key. The default waits until the other process finishes or exits.
- visibility_timeout
Maximum seconds to retry a missing or incomplete result after acquiring its lock. Zero is appropriate for a local filesystem.
- poll_interval
Seconds between visibility retries.
Examples
cache <- shared_cache(tempfile("shared-cache-"))
shared_run(sum(1:10), cache)
#> tarshare compute c0345c72d039
#> [1] 55