I have a shiny dashboard that performs group-bys and ggplot2s from a dataset that is updated every day.
I'm researching a few options for caching:
https://github.com/r-lib/memoise
http://shiny.rstudio-staging.com/articles/plot-caching.html
However, those functions serve if the output remains constant. What if everyday I'm appending a few lines to a dataset. Is there a way to take advantage of caching? Can the cache be updated just to add the new rows of data?
Similar questions were asked here:
Shiny app - Using memoise to cache R values
Example:
Fetching the data every day. This script runs every day and gets new data.
con <- dbConnect(drv = dbDriver(""),
dbname = "db",
host = "connection",
user = "user",
password = "password")
query1 <- dbGetQuery(con,"query1")
query2 <- dbGetQuery(con,"query2")
Maybe a group-by or a join or summarization anything
...
...
...
Finally your have your final dataset.
final <- rbind(query1, query2)
s3saveRDS(x = final,
object = paste0("data", ".rds"),
bucket = "bucketname")
In your shiny application you use it:
final <- s3readRDS(object = "data.rds",
bucket = "bucketname")
How can I benefit from caching if my data has new rows every day?