mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
add working dir to queries
This commit is contained in:
+9
-3
@@ -6,6 +6,9 @@ library(DBI)
|
|||||||
library(xts)
|
library(xts)
|
||||||
library(memoise)
|
library(memoise)
|
||||||
library(cachem)
|
library(cachem)
|
||||||
|
library(digest)
|
||||||
|
|
||||||
|
APP_DIR <- getwd()
|
||||||
|
|
||||||
config <- config::get(file = "config.yml")
|
config <- config::get(file = "config.yml")
|
||||||
|
|
||||||
@@ -615,15 +618,18 @@ get_county_and_state <- function(df) {
|
|||||||
return(result)
|
return(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_dir <- "cache"
|
cache_dir <- file.path(APP_DIR, "cache")
|
||||||
|
cache_logfile <- file.path(APP_DIR, "cachelog")
|
||||||
|
|
||||||
if (!dir.exists(cache_dir)) {
|
if (!dir.exists(cache_dir)) {
|
||||||
dir.create(cache_dir, recursive = TRUE)
|
dir.create(cache_dir, recursive = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
query_cache <- cachem::cache_disk(
|
query_cache <- cachem::cache_disk(
|
||||||
dir = cache_dir,
|
dir = cache_dir,
|
||||||
max_size = 1000 * 1024^2,
|
max_age = 86400, # 24 hours
|
||||||
evict = "lru"
|
evict = "lru",
|
||||||
|
logfile = cache_logfile
|
||||||
)
|
)
|
||||||
|
|
||||||
get_yearly_economics <- memoise(get_yearly_economics, cache = query_cache)
|
get_yearly_economics <- memoise(get_yearly_economics, cache = query_cache)
|
||||||
|
|||||||
Reference in New Issue
Block a user