Skip to content

Commit

Permalink
refactor of memoise functions to use cachem instead of original/old d…
Browse files Browse the repository at this point in the history
…igest package, closes #244
  • Loading branch information
tanho63 committed Mar 31, 2021
1 parent 4a6b517 commit 14537ce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
30 changes: 16 additions & 14 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Type: Package
Package: ffscrapr
Title: API Client for Fantasy Football League Platforms
Version: 1.3.0.03
Version: 1.3.0.04
Authors@R:
c(person(given = "Tan",
family = "Ho",
role = c("aut", "cre"),
email = "tan@tanho.ca"),
person(given = "Tony",
family = "ElHabr",
role = c("ctb"),
email = "anthonyelhabr@gmail.com"))
Description: Helps access various Fantasy Football APIs by handling
authentication and rate-limiting, forming appropriate calls, and returning
tidy dataframes which can be easily connected to other data sources.
family = "Ho",
role = c("aut", "cre"),
email = "tan@tanho.ca"),
person(given = "Tony",
family = "ElHabr",
role = "ctb",
email = "anthonyelhabr@gmail.com"))
Description: Helps access various Fantasy Football APIs by handling
authentication and rate-limiting, forming appropriate calls, and
returning tidy dataframes which can be easily connected to other data
sources.
License: MIT + file LICENSE
URL: https://ffscrapr.dynastyprocess.com,
https://github.com/dynastyprocess/ffscrapr,
Expand All @@ -25,22 +26,23 @@ BugReports: https://github.com/dynastyprocess/ffscrapr/issues
Depends:
R (>= 3.0.0)
Imports:
cachem (>= 1.0.0),
checkmate (>= 2.0.0),
dplyr (>= 1.0.0),
glue (>= 1.3.0),
httr (>= 1.4.0),
jsonlite (>= 1.6.0),
lifecycle,
lubridate (>= 1.5.0),
magrittr (>= 1.5.0),
memoise (>= 1.1.0),
memoise (>= 2.0.0),
purrr (>= 0.3.0),
rappdirs (>= 0.3.0),
ratelimitr (>= 0.4.0),
rlang (>= 0.4.0),
stringr (>= 1.4.0),
tibble (>= 3.0.0),
tidyr (>= 1.0.0),
lifecycle
tidyr (>= 1.0.0)
Suggests:
covr (>= 3.0.0),
curl (>= 4.0.0),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Force MFL playerscores to use season + league specific players call where possible (Fixes #239) (v1.3.0.02)
- Reduce minimum rows for flea rosters test to 200, which fixes an API check issue (v1.3.0.03)
- Fixes CRAN check issue where digest is no longer imported by memoise - switched cache package to cachem which is apparently just better designed. Resolves #244 (v1.3.0.04)
- Eliminate LazyData to silence CRAN note. Resolves #244 (v1.3.0.04)

---

Expand Down
10 changes: 6 additions & 4 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
memoise_option <- getOption("ffscrapr.cache")
# list of memoise options: "memory", "filesystem","off"

if (is.null(memoise_option) || !memoise_option %in% c("memory", "filesystem", "off")) memoise_option <- "memory"
if (is.null(memoise_option) || !memoise_option %in% c("memory", "filesystem", "off")) {
memoise_option <- "memory"
}

if (memoise_option == "filesystem") {
cache_dir <- rappdirs::user_cache_dir(appname = "ffscrapr")
dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE)
cache <- memoise::cache_filesystem(cache_dir)
cache <- cachem::cache_disk(dir = cache_dir)
}

if (memoise_option == "memory") {
cache <- memoise::cache_memory()
cache <- cachem::cache_mem()
}

if (memoise_option != "off") {
Expand Down Expand Up @@ -78,7 +80,7 @@
ff_schedule.espn_conn <<- memoise::memoise(ff_schedule.espn_conn, ~ memoise::timeout(3600), cache = cache)
}

# if(memoise_option=="off") packageStartupMessage("ffscrapr.cache is set to 'off'")
if (memoise_option == "off") packageStartupMessage('Note: ffscrapr.cache is set to "off"')

env <- rlang::env(
user_agent = glue::glue(
Expand Down

0 comments on commit 14537ce

Please sign in to comment.