Where data is cached?

I am trying to move a small Excel macro app to a new app using streamlit, here is what I have done so far
https://xerviewer.herokuapp.com/ , First I have to say what you guys have build is amazing, I am not a dev and managed to make a web app :slight_smile:
the app just read an xer file (it is just a csv file with a lot of tables) and parse it and loaded it to an in memory sqlite DB, I am using st.cache too, the app is hosted in heroku.

my question is : is the data deleted or save it in the server, ideally I want people to use it and feel confident that I can’t read there data ?

thanks

Hi @mim,

By default the cache is stored in memory until the server process is killed. There are some flags you can use to alter this behavior.

    persist : boolean
        Whether to persist the cache on disk.

    max_entries : int or None
        The maximum number of entries to keep in the cache, or None
        for an unbounded cache. (When a new entry is added to a full cache,
        the oldest cached entry will be removed.) The default is None.

    ttl : float or None
        The maximum number of seconds to keep an entry in the cache, or
        None if cache entries should not expire. The default is None.
3 Likes

I’m developping a Streamlit app in a JupyterLab environment. Only my HOME is mounted into an on-demand pod/container. If I set persist=True, what is the specific path where the cache will be stored?

Hi @StefanBrand,

Here’s the code that writes the cached files to disk streamlit/caching.py at d00429604bbc319bc44f3a326f8613607310978d Β· streamlit/streamlit Β· GitHub

It writes the cached .pickle file to ~/.streamlit/cache/. If the path to HOME is /home/, you can find the file in /home/.streamlit/cache/.

Does that help?

Happy Streamlit-ing! :balloon:
Snehan

4 Likes

Does this also apply to st.memo? I’m using persist="disk", but when I do streamlit cache clear I get

Nothing to clear at /home/jovyan/.streamlit/cache.

Also pressing β€œC” inside the app does not clear the cache.

Edit: Cache was gone after killing the Streamlit server. Not sure exactly, which action triggered the cache clearing.

Edit2: st.experimental_memo and st.experimental_singleton do not support clearing of cache via pressing β€œC”: Clearing cache does not work for st.experimental_singleton and st.experimental_memo Β· Issue #3922 Β· streamlit/streamlit Β· GitHub

Edit3: Fixed in "Clear cache" clears memo + singleton (#3937) Β· streamlit/streamlit@46bff68 Β· GitHub

I’d like to better understand how caching and cached values release works. I’m hosting my app on AWS ECS. Can you explain when the memory is released? Is it only after I finish my app session?

Hi @snehankekre Is there a way to change the cache persist location to a custom location.?

3 Likes