Skip to contents

morie functions that persist artifacts to disk (e.g. morie_fetch_siu(cache_html = TRUE)) default to a session-scoped subdirectory of tempdir(), which R automatically removes when the session ends. This is the most conservative CRAN-Policy-compliant default: nothing morie writes ever survives the R session unless the user explicitly opts in.

Usage

morie_cache_dir(subdir = NULL)

Arguments

subdir

Optional subdirectory under the morie cache root (e.g. "siu", "tps"). If NULL, the cache root itself is returned.

Value

A file path string. The directory is not created; callers create it lazily only when they actually persist to disk.

Details

Users who want persistent caching across sessions opt in by passing the result of morie_cache_dir(subdir) as the cache_dir argument, e.g.:


  morie_fetch_siu(
    cache_dir = morie_cache_dir("siu"),
    cache_html = TRUE
  )

The persistent location is tools::R_user_dir("morie", "cache") (R \(\ge\) 4.0), which on Linux defaults to ~/.cache/R/morie/, on macOS to ~/Library/Caches/org.R-project.R/R/morie/, and on Windows to %LOCALAPPDATA%/R/cache/R/morie/. Users can override this location by setting the MORIE_CACHE_DIR environment variable before calling morie_cache_dir().

Active management. CRAN Policy requires persistent caches to be actively managed. Use morie_cache_clear() to empty the persistent cache (or a subdirectory of it). Cached SIU HTML is ~80-100 MB at full sweep, so clearing it occasionally is usually unnecessary, but it is supported.

Examples

# Persistent cache root (does not write anything to disk):
morie_cache_dir()
#> [1] "/home/runner/.cache/R/morie"
# Per-subsystem persistent path:
morie_cache_dir("siu")
#> [1] "/home/runner/.cache/R/morie/siu"