| catr_set_cache_dir | R Documentation |
Configure the cache directory used by CatastRo. Use
Sys.getenv("CATASTROESP_CACHE_DIR") or catr_detect_cache_dir() to inspect
the current path.
catr_set_cache_dir(
cache_dir = NULL,
overwrite = FALSE,
install = FALSE,
verbose = TRUE
)
catr_detect_cache_dir()
cache_dir |
Path to a cache directory. If |
overwrite |
Logical. Whether to overwrite an existing
|
install |
Logical. Whether to store the path locally for use in future
sessions. Defaults to |
verbose |
Logical. Whether to display informational messages. |
By default, when no cache_dir is set, CatastRo uses a directory
inside base::tempdir(), so files are temporary and are removed when the R
session ends. To persist a cache across R sessions, use
catr_set_cache_dir(cache_dir, install = TRUE), which writes the chosen path
to a small configuration file under
tools::R_user_dir("CatastRo", "config").
catr_set_cache_dir() returns a character string
containing the cache
directory path, invisibly. This function is called for its side effects.
catr_detect_cache_dir() returns a character string
containing the cache
directory path used in this session.
Source files are cached after download. CatastRo implements the following caching options:
For occasional use, rely on the default tempdir()-based cache without
installing it.
Modify the cache for a single session by setting
catr_set_cache_dir(cache_dir = "a/path/here").
For reproducible workflows, install a persistent cache with
catr_set_cache_dir(cache_dir = "a/path/here", install = TRUE).
This cache is kept across R sessions.
For caching specific files, use the cache_dir argument in the
corresponding function.
Cached files can occasionally become corrupt. In that case, try downloading
the data by setting update_cache = TRUE in the corresponding function.
If a download fails, try another download method and save the file in
cache_dir. Use verbose = TRUE to inspect the API query
and catr_detect_cache_dir() to identify your cache path.
In CatastRo >= 1.0.0, the location of the configuration file has
moved from rappdirs::user_config_dir("CatastRo", "R") to
tools::R_user_dir("CatastRo", "config"). A migration function moves
previous configuration files to the new location and displays a message.
This message appears only once.
tools::R_user_dir() defines platform-specific user directories.
Manage the local cache:
catr_clear_cache()
# Caution! This modifies your current state
## Not run:
my_cache <- catr_detect_cache_dir()
# Set an example cache
ex <- file.path(tempdir(), "example", "cachenew")
catr_set_cache_dir(ex)
catr_detect_cache_dir()
# Restore initial cache
catr_set_cache_dir(my_cache)
identical(my_cache, catr_detect_cache_dir())
## End(Not run)
catr_detect_cache_dir()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.