Removes all cached pr_get_tree() / pr_date_tree() results. By
default asks for confirmation before deleting; pass confirm = FALSE
to skip the prompt (useful in scripts).
Arguments
- confirm
Logical. Ask interactively before deleting? Default
TRUE. Ignored in non-interactive sessions (deletion proceeds).- source
A length-1 character vector or
NULL. If non-NULL, only entries from that backend are cleared (e.g."datelife"to wipe only datelife cache after a database refresh). IfNULL(default), all entries are cleared.
Examples
# Demo against a throwaway cache so the user's real cache is untouched
old_opt <- getOption("prepR4pcm.cache_dir")
tmp_cache <- file.path(tempdir(), "prepR4pcm-cache-demo")
pr_tree_cache_dir(tmp_cache)
# Drop two dummy entries so there is something to clear:
dir.create(file.path(tmp_cache, "fishtree"), showWarnings = FALSE)
dir.create(file.path(tmp_cache, "rotl"), showWarnings = FALSE)
saveRDS(NULL, file.path(tmp_cache, "fishtree", "abc.rds"))
saveRDS(NULL, file.path(tmp_cache, "rotl", "def.rds"))
pr_tree_cache_status() # 2 entries
#> source hash size_kb modified
#> 2 rotl def 0 2026-06-16 10:09:42
#> 1 fishtree abc 0 2026-06-16 10:09:42
pr_tree_cache_clear(confirm = FALSE) # removes both
#> ✔ Removed 2 cache files.
pr_tree_cache_status() # empty
#> [1] source hash size_kb modified
#> <0 rows> (or 0-length row.names)
# Restore the previous cache directory
options(prepR4pcm.cache_dir = old_opt)