| esp_set_cache_dir | R Documentation |
This function stores your cache_dir path on your local machine and
loads it for future sessions. Type Sys.getenv("MAPSPAIN_CACHE_DIR") to
find your cached path, or use esp_detect_cache_dir().
esp_set_cache_dir(
cache_dir = NULL,
overwrite = FALSE,
install = FALSE,
verbose = TRUE
)
esp_detect_cache_dir()
cache_dir |
A path to a cache directory. When |
overwrite |
logical. If |
install |
logical. If |
verbose |
logical. If |
By default, when no cache_dir is set, the package uses a folder inside
base::tempdir() (files are temporary and removed when the R session
ends). To persist a cache across R sessions, use
esp_set_cache_dir(cache_dir, install = TRUE), which writes the chosen
path to a configuration file under tools::R_user_dir("mapSpain", "config").
esp_set_cache_dir() returns an (invisible) character string with the path
to your cache_dir. It is primarily called for its side effect.
esp_detect_cache_dir() returns the path to the cache_dir used in the
current session.
Some files can be read from its online source without caching using the
option cache = FALSE. Otherwise the source file will be downloaded to
your computer. mapSpain implements the following caching options:
For occasional use, rely on the default tempdir()-based cache (no
install).
Modify the cache for a single session by setting
esp_set_cache_dir(cache_dir = "a/path/here").
For reproducible workflows, install a persistent cache with
esp_set_cache_dir(cache_dir = "a/path/here", install = TRUE) that
persists across R sessions.
For caching specific files, use the cache_dir argument in the
corresponding function.
Sometimes cached files may be corrupted. In that case, try re-downloading
the data by setting update_cache = TRUE in the corresponding function.
If you experience download problems, try downloading the file by another
method and save it to your cache_dir. Use verbose = TRUE to debug the
API query and esp_detect_cache_dir() to identify your cache path.
In mapSpain >= 1.0.0, the configuration file location has
moved from rappdirs::user_config_dir("mapSpain", "R") to
tools::R_user_dir("mapSpain", "config"). A migration function automatically
transfers previous configuration files from the old to the new location.
A message appears once during this migration.
tools::R_user_dir()
Other cache utilities:
esp_clear_cache()
# Don't run this! It would modify your current state
## Not run:
my_cache <- esp_detect_cache_dir()
# Set an example cache
ex <- file.path(tempdir(), "example", "cachenew")
esp_set_cache_dir(ex)
esp_detect_cache_dir()
# Restore initial cache
esp_set_cache_dir(my_cache)
identical(my_cache, esp_detect_cache_dir())
## End(Not run)
esp_detect_cache_dir()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.