rdesk_storage provides file-based persistent storage for desktop applications.
On Windows, it handles multi-user data isolation by mapping key-value stores to the
correct system folder depending on the requested type.
Usage
rdesk_storage(app_name, type = c("local", "roaming", "shared"))Details
The three storage types correspond to different Windows user profile folders:
- roaming
User roaming folder (APPDATA). Suitable for per-user preferences that should follow the user across machines when roaming profiles are enabled.
- local
User local folder (LOCALAPPDATA). Suitable for cache, history, or data that is specific to one machine.
- shared
Machine-wide folder (PROGRAMDATA). Suitable for configuration shared by all users on the same computer.
Outside a bundled application (e.g. during development or R CMD check), all
storage types fall back to a subdirectory of tempdir() to comply with
CRAN policies on persistent file writes.
See also
RDeskStorage for the full method reference.
Examples
# Create a local storage manager for an app called "MyApp"
s <- rdesk_storage("MyApp", "local")
# Store and retrieve a value
s$set("last_filter", "cyl == 6")
stopifnot(s$get("last_filter") == "cyl == 6")
# List all keys
s$keys()
#> [1] "last_filter"
# Remove a specific key
s$remove("last_filter")
