diff --git a/R/get_dataset.R b/R/get_dataset.R index ba24907..d7a80fb 100644 --- a/R/get_dataset.R +++ b/R/get_dataset.R @@ -20,6 +20,7 @@ #' @template version #' @template envvars #' @template dots +#' @param use_cache one of `"disk"`, `"session"`, or `"none"`, describing how datasets are cached to reduce network traffic. See \code{\link{cache_dataset}} for details. #' @return A list of class \dQuote{dataverse_dataset} or a list of a form dependent #' on the specific metadata block retrieved. \code{dataset_files} returns a list of #' objects of class \dQuote{dataverse_file}. @@ -45,15 +46,16 @@ get_dataset <- function( version = ":latest", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) { - dataset <- dataset_id(dataset, key = key, server = server, ...) + dataset <- dataset_id(dataset, key = key, server = server, ..., use_cache = use_cache) if (!is.null(version)) { u <- paste0(api_url(server), "datasets/", dataset, "/versions/", version) } else { u <- paste0(api_url(server), "datasets/", dataset) } - r <- api_get(u, ..., key = key) + r <- api_get(u, ..., key = key, use_cache = use_cache) parse_dataset(r) } @@ -69,16 +71,17 @@ dataset_metadata <- function( block = "citation", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) { - dataset <- dataset_id(dataset, key = key, server = server, ...) + dataset <- dataset_id(dataset, key = key, server = server, ..., use_cache = use_cache) if (!is.null(block)) { u <- paste0(api_url(server), "datasets/", dataset, "/versions/", version, "/metadata/", block) } else { u <- paste0(api_url(server), "datasets/", dataset, "/versions/", version, "/metadata") } - r <- api_get(u, ..., key = key) + r <- api_get(u, ..., key = key, use_cache = use_cache) jsonlite::fromJSON(r)[["data"]] } @@ -89,11 +92,12 @@ dataset_files <- function( version = ":latest", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) { - dataset <- dataset_id(dataset, key = key, server = server, ...) + dataset <- dataset_id(dataset, key = key, server = server, ..., use_cache = use_cache) u <- paste0(api_url(server), "datasets/", dataset, "/versions/", version, "/files") - r <- api_get(u, ..., key = key) + r <- api_get(u, ..., key = key, use_cache = use_cache) out <- jsonlite::fromJSON(r, simplifyDataFrame = FALSE)$data structure(lapply(out, `class<-`, "dataverse_file")) } diff --git a/R/onload.R b/R/onload.R index e0fbc38..a129f9e 100644 --- a/R/onload.R +++ b/R/onload.R @@ -2,26 +2,19 @@ #' #' @importFrom memoise memoise .onLoad <- function(libname, pkgname) { - # a <- Sys.getenv("DATAVERSE_SERVER") - # if(a == "") { - # Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu") - # } + ## + ## 'memoise' httr::GET calls + ## - ## implement API disk cache via 'memoise' - cache_directory <- file.path( - tools::R_user_dir(pkgname, "cache"), - "api_cache" - ) - get <- api_get_impl - if (!dir.exists(cache_directory)) { - status <- dir.create(cache_directory, recursive = TRUE) - if (!status) - warning("'dataverse' failed to create API cache") - } - if (dir.exists(cache_directory)) { - # disk cache with max age 30 days - cache <- cache_disk(cache_directory, max_age = 60 * 60 * 24 * 30) - get <- memoise(get, cache = cache) + ## API session cache + api_get_session_cache <<- memoise(api_get_impl) + + ## API disk cache + cache_path <- cache_path() + if (dir.exists(cache_path)) { + # disk cache, no age or size limits + cache <- cache_disk(cache_path) + get_disk <- memoise(api_get_impl, cache = cache) } - api_get_memoized <<- get + api_get_disk_cache <<- get_disk } diff --git a/R/utils.R b/R/utils.R index dc62a13..4b05544 100644 --- a/R/utils.R +++ b/R/utils.R @@ -27,9 +27,12 @@ dataset_id.character <- function(x, key = Sys.getenv("DATAVERSE_KEY"), server = x <- prepend_doi(x) u <- paste0(api_url(server), "datasets/:persistentId?persistentId=", x) r <- tryCatch({ - api_get(u, ..., key = key) + api_get(u, ..., key = key) }, error = function(e) { - stop("Could not retrieve Dataset ID from persistent identifier!") + stop( + "Could not retrieve Dataset ID from persistent identifier! ", + conditionMessage(e) + ) }) jsonlite::fromJSON(r)[["data"]][["id"]] } @@ -206,21 +209,23 @@ api_url <- function(server = Sys.getenv("DATAVERSE_SERVER"), prefix = "api/") { } ## common httr::GET() uses -#' @importFrom checkmate assert_character assert_logical -api_get <- function(url, ..., key = NULL, as = "text", use_cache = as.logical(Sys.getenv("DATAVERSE_USE_CACHE", TRUE))) { - assert_character(url, any.missing = FALSE, len = 1L, null.ok = TRUE) - assert_character(key, any.missing = FALSE, len = 1L, null.ok = TRUE) - assert_character(as, any.missing = FALSE, len = 1L, null.ok = TRUE) - assert_logical(use_cache, any.missing = FALSE, len = 1L) - if (use_cache) { - get <- api_get_memoized - } else { - get <- api_get_impl - } +#' @importFrom checkmate assert_string +api_get <- function(url, ..., key = NULL, as = "text", use_cache = Sys.getenv("DATAVERSE_USE_CACHE", "session")) { + assert_string(url) + assert_string(key, null.ok = TRUE) + assert_string(as, null.ok = TRUE) + assert_use_cache(use_cache) + get <- switch( + use_cache, + "none" = api_get_impl, + "session" = api_get_session_cache, + "disk" = api_get_disk_cache, + stop("unknown value for 'use_cache'") + ) get(url, ..., key = key, as = as) } -## cache implemented via memoization; memoized function defined in +## cache implemented via memoization; memoized functions defined in ## .onLoad() api_get_impl <- function(url, ..., key = NULL, as = "text") { if (!is.null(key)) @@ -230,7 +235,9 @@ api_get_impl <- function(url, ..., key = NULL, as = "text") { httr::content(r, as = as, encoding = "UTF-8") } -api_get_memoized <- NULL +api_get_session_cache <- NULL # per-session memoisatoin + +api_get_disk_cache <- NULL # 'permanent' memoisation # parse dataset response into list/dataframe parse_dataset <- function(out) { diff --git a/man-roxygen/dots.R b/man-roxygen/dots.R index 38907cc..89f575e 100644 --- a/man-roxygen/dots.R +++ b/man-roxygen/dots.R @@ -1,6 +1,5 @@ #' @param ... Additional arguments passed to an HTTP request function, #' such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -#' \code{\link[httr]{DELETE}}. By default, HTTP requests use -#' values cached from previous identical calls. Use -#' \code{use_cache=FALSE} (or `Sys.setenv(DATAVERSE_USE_CACHE = -#' FALSE)` if cached API calls are not desired. +#' \code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +#' on how the *R* dataverse package uses disk and session caches to +#' improve network performance. diff --git a/man/URLs.Rd b/man/URLs.Rd index 947f80f..7462ba1 100644 --- a/man/URLs.Rd +++ b/man/URLs.Rd @@ -87,9 +87,9 @@ no ingested version, is set to NA. Note in \verb{get_dataframe_*}, \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} \item{filename}{Filename of the dataset, with file extension as shown in Dataverse (for example, if nlsw88.dta was the original but is displayed as the ingested diff --git a/man/add_dataset_file.Rd b/man/add_dataset_file.Rd index 0d9d16a..f1fbbd2 100644 --- a/man/add_dataset_file.Rd +++ b/man/add_dataset_file.Rd @@ -49,9 +49,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} \item{id}{An integer specifying a file identifier; or, if \code{doi} is specified, a character string specifying a file name within the DOI-identified dataset; or an diff --git a/man/add_file.Rd b/man/add_file.Rd index fdee650..a2f30a9 100644 --- a/man/add_file.Rd +++ b/man/add_file.Rd @@ -32,9 +32,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ An object of class \dQuote{dataset_atom}. diff --git a/man/create_dataset.Rd b/man/create_dataset.Rd index 8fb1525..3e5f0d3 100644 --- a/man/create_dataset.Rd +++ b/man/create_dataset.Rd @@ -41,9 +41,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} \item{dataset}{A character specifying a persistent identification ID for a dataset, for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class diff --git a/man/create_dataverse.Rd b/man/create_dataverse.Rd index 83bb08f..da7ff59 100644 --- a/man/create_dataverse.Rd +++ b/man/create_dataverse.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/dataset_atom.Rd b/man/dataset_atom.Rd index 5e26711..4584a06 100644 --- a/man/dataset_atom.Rd +++ b/man/dataset_atom.Rd @@ -37,9 +37,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. For \code{dataset_atom}, an object of class \dQuote{dataset_atom}. diff --git a/man/dataset_versions.Rd b/man/dataset_versions.Rd index 99731b5..e51cb3e 100644 --- a/man/dataset_versions.Rd +++ b/man/dataset_versions.Rd @@ -31,9 +31,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list of class \dQuote{dataverse_dataset_version}. diff --git a/man/dataverse_metadata.Rd b/man/dataverse_metadata.Rd index 4656e0a..b39c0c1 100644 --- a/man/dataverse_metadata.Rd +++ b/man/dataverse_metadata.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list diff --git a/man/delete_dataset.Rd b/man/delete_dataset.Rd index f3b8d5d..62e0e78 100644 --- a/man/delete_dataset.Rd +++ b/man/delete_dataset.Rd @@ -31,9 +31,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A logical. diff --git a/man/delete_dataverse.Rd b/man/delete_dataverse.Rd index aefc0ca..2e0803e 100644 --- a/man/delete_dataverse.Rd +++ b/man/delete_dataverse.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A logical. diff --git a/man/delete_file.Rd b/man/delete_file.Rd index bc2ddcc..ab5c5bf 100644 --- a/man/delete_file.Rd +++ b/man/delete_file.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ If successful, a logical \code{TRUE}, else possibly some information. diff --git a/man/delete_sword_dataset.Rd b/man/delete_sword_dataset.Rd index e9d0c66..f77326c 100644 --- a/man/delete_sword_dataset.Rd +++ b/man/delete_sword_dataset.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ If successful, a logical \code{TRUE}, else possibly some information. diff --git a/man/files.Rd b/man/files.Rd index a72e861..fcbabe3 100644 --- a/man/files.Rd +++ b/man/files.Rd @@ -101,9 +101,9 @@ no ingested version, is set to NA. Note in \verb{get_dataframe_*}, \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} \item{filename}{Filename of the dataset, with file extension as shown in Dataverse (for example, if nlsw88.dta was the original but is displayed as the ingested diff --git a/man/get_dataset.Rd b/man/get_dataset.Rd index 8c74c1d..16630d9 100644 --- a/man/get_dataset.Rd +++ b/man/get_dataset.Rd @@ -11,7 +11,8 @@ get_dataset( version = ":latest", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) dataset_metadata( @@ -20,7 +21,8 @@ dataset_metadata( block = "citation", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) dataset_files( @@ -28,7 +30,8 @@ dataset_files( version = ":latest", key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), - ... + ..., + use_cache = Sys.getenv("DATAVERSE_USE_CACHE", cache_dataset(version)) ) } \arguments{ @@ -53,9 +56,11 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} + +\item{use_cache}{one of \code{"disk"}, \code{"session"}, or \code{"none"}, describing how datasets are cached to reduce network traffic. See \code{\link{cache_dataset}} for details.} \item{block}{A character string specifying a metadata block to retrieve. By default this is \dQuote{citation}. Other values may be available, depending diff --git a/man/get_dataverse.Rd b/man/get_dataverse.Rd index 485c73d..7925955 100644 --- a/man/get_dataverse.Rd +++ b/man/get_dataverse.Rd @@ -40,9 +40,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list of class \dQuote{dataverse}. diff --git a/man/get_facets.Rd b/man/get_facets.Rd index 546a8f2..6f86052 100644 --- a/man/get_facets.Rd +++ b/man/get_facets.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/get_file_metadata.Rd b/man/get_file_metadata.Rd index 283dce0..7be3b2c 100644 --- a/man/get_file_metadata.Rd +++ b/man/get_file_metadata.Rd @@ -42,9 +42,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A character vector containing a DDI diff --git a/man/get_user_key.Rd b/man/get_user_key.Rd index 81d26fc..be2d2b8 100644 --- a/man/get_user_key.Rd +++ b/man/get_user_key.Rd @@ -15,9 +15,9 @@ get_user_key(user, password, server = Sys.getenv("DATAVERSE_SERVER"), ...) \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/initiate_sword_dataset.Rd b/man/initiate_sword_dataset.Rd index 19c62eb..170fea8 100644 --- a/man/initiate_sword_dataset.Rd +++ b/man/initiate_sword_dataset.Rd @@ -32,9 +32,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ An object of class \dQuote{dataset_atom}. diff --git a/man/list_datasets.Rd b/man/list_datasets.Rd index 0882a89..bc7cb77 100644 --- a/man/list_datasets.Rd +++ b/man/list_datasets.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/publish_dataset.Rd b/man/publish_dataset.Rd index 9644a98..0ebd463 100644 --- a/man/publish_dataset.Rd +++ b/man/publish_dataset.Rd @@ -34,9 +34,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/publish_dataverse.Rd b/man/publish_dataverse.Rd index ac69533..2c611c1 100644 --- a/man/publish_dataverse.Rd +++ b/man/publish_dataverse.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/publish_sword_dataset.Rd b/man/publish_sword_dataset.Rd index e9c0b81..0899f68 100644 --- a/man/publish_sword_dataset.Rd +++ b/man/publish_sword_dataset.Rd @@ -29,9 +29,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list. diff --git a/man/service_document.Rd b/man/service_document.Rd index e753edd..1c48bf8 100644 --- a/man/service_document.Rd +++ b/man/service_document.Rd @@ -26,9 +26,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list of class \dQuote{sword_service_document}, possibly with one or more \dQuote{sword_collection} entries. The latter are SWORD representations of a Dataverse. These can be passed to other SWORD API functions, e.g., for creating a new dataset. diff --git a/man/set_dataverse_metadata.Rd b/man/set_dataverse_metadata.Rd index de8620f..4f85106 100644 --- a/man/set_dataverse_metadata.Rd +++ b/man/set_dataverse_metadata.Rd @@ -35,9 +35,9 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \item{...}{Additional arguments passed to an HTTP request function, such as \code{\link[httr]{GET}}, \code{\link[httr]{POST}}, or -\code{\link[httr]{DELETE}}. By default, HTTP requests use -values cached from previous identical calls. Use -\code{use_cache=FALSE} (or \code{Sys.setenv(DATAVERSE_USE_CACHE = FALSE)} if cached API calls are not desired.} +\code{\link[httr]{DELETE}}. See \code{\link{use_cache}} for details +on how the \emph{R} dataverse package uses disk and session caches to +improve network performance.} } \value{ A list diff --git a/tests/testthat.R b/tests/testthat.R index c520ba2..ef235f0 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -17,7 +17,7 @@ if (!requireNamespace("yaml", quietly = TRUE)) { Sys.setenv( DATAVERSE_SERVER = config$server, DATAVERSE_KEY = config$api_token, - DATAVERSE_USE_CACHE = FALSE + DATAVERSE_USE_CACHE = "none" ) # To better identify the source of problems, check if the token is expired.