2

I am currently experiencing issues with caching items for use within Shiny (in R) and would like to know the correct way of doing this. An example would be that I need to load a large data.table using readRDS which is then sliced and diced various ways and a number of charts created. I can easily cache the file load by using

LoadFile <- memoise(function(filepath) {...})

I am, however, seeing problems when I try to cache calculation results. If I have

f(data.table, data.table)

Then memoise-ing f does not seem to help as I witness no speed-up and very similar times between first and subsequent calls indicating no caching is occurring.

Is this a known shortcoming of memoise? Are there any other caching libraries I can use that get around issues of the

cachefunction(myfunction(param1,param2))

design pattern? Namely that if param1 and param2 are large complex data types then formulating a key is time consuming and/or may not be occurring properly.

In this instance I really want something more of the design

cache(mykey, myvalue, [expiry date/time])

Memory based caching is what I am ideally after as file based caching is too slow in a web context for what I am doing.

Mark
  • 43
  • 7

0 Answers0