This is a DISCUSSION ON CACHING. I hope you will join. Please share your comments and suggestions.
I would like to start optimize the way I use caching. I wanna do this because I want to improve my development experience and my user experience. I need things to be faster for me and my users.
I can use the simple cache dictionary in
pn.state.cache but it is simple I need something better.
- If possible I would like to avoid setting up additional infrastructure to depend on like redis or memcache. I would like to keep things simple.
- Maybe it is just me who don’t want to learn yet another thing and maintain it
- The caching should be easy and powerful to use just not for me but also for my analyst, traders colleagues and the Panel community.
- My data and usage is not so large that I believe I need to store it else where. My laptop and mounted drive in my docker container would be fine.
- My objects are DataFrames, HoloViews, Plotly and Echarts plots, Some machine learning models etc. They should be easy to cache.
My workflow is developing in VS code and serving my Panel app with the
python -m panel serve 'app.py' --dev. When I change the code the server reloads. But then it has to reload my data, plots etc. again. That is slow. Mostly bound by slow database calls.
- I need the data to be persisted between server restarts.
- I want the option to not persist my other objects like plots etc. as they change.
- Optimally I would like the cache to be clever enough to know if the cache result of specific functions are still valid. Streamlit supports this.
- I would also like the caching to be easy to apply to functions via a
- I would like it to be easy to clear the cache manually via a button or script I can run.
My apps should be fast and snappy and the data up to date.
- I need to be able to set the expiration of specific data or collections of data either relative (in 5 mins) or absolutely (at 16:00).
- The cache should be robust when I have many users and concurrent requests. It should work in a Panel/ Bokeh/ Tornado environment.
- I would like to be able to add to and update the cache outside of my app by running scripts on regular intervals.
- I should be able to control whether I cache globally, for the specific user or the specific session.
- One question that I would also like an answer to. Should I combine memory and desk caching to make things as fast as possible? And enable to option of persisting hard to serialize/ pickle/ cache objects in memory?
So my question is. HOW SHOULD I SETUP MORE ADVANCED CACHING? ANY SUGGESTIONS?