I have a shiny app with three tabs, two of which are almost identical except for the input data, so I put that into a module. In the module, I have one input, and a leaflet plot and a reactable output. I tried using bindCache
on the plot and the table - not because the computations are very heavy, but because I learned about it and wanted to apply it. It turns out that when I use bindCache
like this (github repo), it has just one cache for both modules, which leads to a wrong output. Adding the parameter cache = "session"
does not help either. So is there a possibility to assign a different cache to each instance of the shiny module?
I think you should bindCache on the properties that would lead the output to give different results
i.e. in your case also response_times, and plot_title
Ok! but that means I do it outside the module, right?
I dont think so... Why ?
because both of these are inputs to the module, and the thing I am aiming to cache are the table and plot created within the module from these inputs. So to me that sounds as if caching the inputs does not help me achieve faster plotting times, which is what I'd want to gain from the caching. Or maybe I am getting it wrong?
the table and plot presumably take time to generate from their inputs; the hope of cacheing would be that retrieving a previously generated table (or plot) as one previously made , by reading it from the cache rather than running the generation code, is faster . This can not be assumed, it should be profiled.
The widest benefits come from a shared cache, a common cache across multiple similar modules,and across all user sessions. as far as I know you need to set the bindCache properties within your module, (rather than outside of it; how might you attempt that anyway?)
yes exactly, I tried using it inside the module. This would then work also across user sessions but only if I use the module only once. As I use it twice, each with different inputs, I end up plotting the same thing twice even though I feed each module a different input! So the question is how can I use caching in modules when I have multiple instances of each module, which should produce different outputs. Does that make sense?
I answered that previously; your cache key was insufficient.
if you have output cached by input$year_switch only
but should give different results from the same input$year_switch but a different response_times
then this bindCache properties are insufficiently set; year_switch is not enough on its own, if other things should matter to generating different outputs; otherwise you risk the cache showing you the same output for every module looking at the same year_switch even as their response_times differ.
ah, now I understand what you meant before. I'll try that, thanks!
This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.