So the docs say that the format for cache is st.cache(func=None, persist=False, allow_output_mutation=False, show_spinner=True, suppress_st_warning=False, hash_funcs=None, max_entries=None, ttl=None)
I wonder what persist really means here. Does that mean we can save cache on users’s local storage rather than using our server’s memory/disk?
Another thing: if the cache is, by default, stored in the memory of the server and destroyed once the session ends, how does streamlit become aware of the familiarity with the function the next time the same arguments are passed now that the cache is gone?
The docstrings for the new commands explain what the persist param means:
persist(str or boolean or None): Optional location to persist cached data to. Passing “disk” (or True) will persist the cached data to the local disk. None (or False) will disable persistence. The default is None.
Does that mean we can save cache on users’s local storage rather than using our server’s memory/disk?
It means that when passing "disk" or True to persist, Streamlit will persist the cached data to the local disk where the application is deployed. i.e. the remote server, not the users’ local disk.
Another thing: if the cache is, by default, stored in the memory of the server and destroyed once the session ends, how does streamlit become aware of the familiarity with the function the next time the same arguments are passed now that the cache is gone?
The caching mechanism is explained in detail in the new caching docs:
@snehankekre Gotchu. The reason I asked this is because we recently started caching a big function and the RAM has been going up exponentially since then. Everything else has stayed the same so we suspected that cache might be causing increase in RAM.
@snehankekre Do you know if the stores cache persists after the process is killed? I understand that it is saved in disk storage instead of memory, but does this mean that the cache will still be accessible the next time the app is run? If so, where can I find the stores cache’s location on my machine?
@snehankekre to similar question, to persist just indefintely persist data to disk? is there way to have janitor process or something that ensures data gets deleted after certain amount of time or only so much memory stored on disk (namely just worry about using persist and data staying on disk of server indefinitely)?
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.