From d763bc1ea09e9fea0932ef359e7b0aa0aacd88c4 Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Thu, 25 Dec 2025 02:03:27 -0500 Subject: [PATCH] add working dir to queries --- app/queries.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/queries.R b/app/queries.R index 84d9afb..c95e6d5 100644 --- a/app/queries.R +++ b/app/queries.R @@ -6,6 +6,9 @@ library(DBI) library(xts) library(memoise) library(cachem) +library(digest) + +APP_DIR <- getwd() config <- config::get(file = "config.yml") @@ -615,15 +618,18 @@ get_county_and_state <- function(df) { return(result) } -cache_dir <- "cache" +cache_dir <- file.path(APP_DIR, "cache") +cache_logfile <- file.path(APP_DIR, "cachelog") + if (!dir.exists(cache_dir)) { dir.create(cache_dir, recursive = TRUE) } query_cache <- cachem::cache_disk( dir = cache_dir, - max_size = 1000 * 1024^2, - evict = "lru" + max_age = 86400, # 24 hours + evict = "lru", + logfile = cache_logfile ) get_yearly_economics <- memoise(get_yearly_economics, cache = query_cache)