From b9c0788ecd341c34d0694ce0ffc614fa7e567474 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Fri, 29 Sep 2023 12:17:34 -0600 Subject: [PATCH 1/3] Let's just finally rip out these Connect user and content caches --- R/board_connect.R | 31 +++----------------------- man/board_connect.Rd | 8 ------- tests/testthat/_snaps/board_connect.md | 4 ++-- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/R/board_connect.R b/R/board_connect.R index 2fd8ec96..e9749c8d 100644 --- a/R/board_connect.R +++ b/R/board_connect.R @@ -30,16 +30,8 @@ #' )) #' board %>% pin_read("numbers") #' ``` -#' -#' You can find the URL of a pin with [pin_browse()]. #' -#' # Local caching for Posit Connect -#' -#' The pins package maintains local per-session caches for _users_ and _content_ -#' from your Connect server. If your cache gets into a bad state (for example, -#' user names have changed on the server or a pin was deleted on the server, but -#' your local machine doesn't know about the change yet), you can clear your -#' local cache by restarting your R session. +#' You can find the URL of a pin with [pin_browse()]. #' #' @inheritParams new_board #' @inheritParams board_url @@ -437,21 +429,9 @@ board_pin_find.pins_board_connect <- function(board, # Content ----------------------------------------------------------------- -the <- rlang::new_environment() -the$connect_content_cache <- rlang::new_environment() -the$connect_user_cache <- rlang::new_environment() - rsc_content_find <- function(board, name, version = NULL, warn = TRUE) { - name <- rsc_parse_name(name) - content <- rlang::env_cache( - env = the$connect_content_cache, - nm = name$full %||% name$name, - default = rsc_content_find_live(board, name, version = NULL, warn = TRUE) - ) - content -} -rsc_content_find_live <- function(board, name, version = NULL, warn = TRUE) { + name <- rsc_parse_name(name) # https://docs.rstudio.com/connect/api/#get-/v1/content json <- rsc_GET(board, "v1/content", list(name = name$name)) @@ -573,7 +553,6 @@ rsc_content_version_cached <- function(board, guid) { rsc_content_delete <- function(board, name) { content <- rsc_content_find(board, name) rsc_DELETE(board, rsc_v1("content", content$guid)) - env_unbind(the$connect_content_cache, name) invisible(NULL) } @@ -588,11 +567,7 @@ rsc_parse_name <- function(x) { } rsc_user_name <- function(board, guid) { - rlang::env_cache( - env = the$connect_user_cache, - nm = guid, - rsc_GET(board, rsc_v1("users", guid))$username - ) + rsc_GET(board, rsc_v1("users", guid))$username } # helpers ----------------------------------------------------------------- diff --git a/man/board_connect.Rd b/man/board_connect.Rd index 0c8592b4..f5fb2242 100644 --- a/man/board_connect.Rd +++ b/man/board_connect.Rd @@ -104,14 +104,6 @@ board \%>\% pin_read("numbers") You can find the URL of a pin with \code{\link[=pin_browse]{pin_browse()}}. } -\section{Local caching for Posit Connect}{ -The pins package maintains local per-session caches for \emph{users} and \emph{content} -from your Connect server. If your cache gets into a bad state (for example, -user names have changed on the server or a pin was deleted on the server, but -your local machine doesn't know about the change yet), you can clear your -local cache by restarting your R session. -} - \examples{ \dontrun{ board <- board_connect() diff --git a/tests/testthat/_snaps/board_connect.md b/tests/testthat/_snaps/board_connect.md index 97e60447..611dfe1c 100644 --- a/tests/testthat/_snaps/board_connect.md +++ b/tests/testthat/_snaps/board_connect.md @@ -30,7 +30,7 @@ Code rsc_content_find(board, "marjory/test-partial") Condition - Error in `rsc_content_find_live()`: + Error in `rsc_content_find()`: ! Can't find pin named 'test-partial' with owner 'marjory' # can create and delete content @@ -47,7 +47,7 @@ Code rsc_content_delete(board, "test-1") Condition - Error in `rsc_content_find_live()`: + Error in `rsc_content_find()`: ! Can't find pin called "test-1" i Use `pin_list()` to see all available pins in this board From 14b80a2de2a73503e25a4a8738540215c693af79 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Fri, 29 Sep 2023 12:22:07 -0600 Subject: [PATCH 2/3] Update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index ba82882e..5784176d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # pins (development version) +* Removed content and user caches for Connect altogether. Now, we look up + usernames and content on the Connect server every time (#793). + # pins 1.2.2 * Fixed how dots are checked in `pin_write()` to make user-facing messages more From 062e87cbcc1dfcd3f96a4587a3e134126385a992 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Fri, 29 Sep 2023 13:00:08 -0600 Subject: [PATCH 3/3] Update NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 44aaeef7..abe96f47 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Changed the function signature of `pin_write()` so arguments like `type` and `title` must be passed by name and not position (#792). +## Other improvements + * Removed content and user caches for Connect altogether. Now, we look up usernames and content on the Connect server every time (#793).