Caching data globally

Hello everyone!

I am trying to cache my data through all user sessions, i.e, cache the data on the server till the server goes off.
I am using the st.cache_data function, but i got confused about some topics:

  • Does st.cache_date (with default args) caches the data through all user sessions of that application? Example: if user1 loads the application and the cached function gets called for the first time, when user2 opens a new user session, does that function runs again or the cached data gets used for that user as well?

  • When looking the documentation, i saw a paremeter called “persist”. From my understanding, if i use the default value (“None”) the cache only applies for that user, as it does not get saved on the server. If i set persist=True, does the cache works for all users of that application until the application is on?
    If it doesn’t what would be the difference between persist vs non-persist? And what would be the solution here, to use st.cache_resource?

  • If I have to rerun the cached function each day, then applying a current_date paremeter to this function is enough to achieve it? As the current_date changes, the args of the function will change and then the function is runned again?

Thanks in advance!

Yes.

I think that is wrong. The cache is available no matter it is stored on disk or in memory. In fact, if it is stored on disk then it needs to be read into the memory before it can be returned.

Yes, but that would leak memory (or disk?) by keeping the return values for each day even when you no longer need them. You can avoid that by using max_entries.