To be clear, there’s still no way to clear the cache with “C” like before, or via the hamburger menu, correct?
Hi, I upgraded to the latest version, but I’m not able to use caching.clear_singleton_cache()
AttributeError: module ‘streamlit.caching’ has no attribute ‘clear_singleton_cache’
Hi @kimsb2429, welcome to the community!
The command you’re looking for is st.experimental_singleton.clear()
. Calling this command will clear all singleton caches.
If you want to clear the singleton cache of a specific function, say foo()
, you can use foo.clear()
, provided foo()
is decorated with @st.experimental_singleton
.
Best,
Snehan
That’s correct. You can clear the cache with “C” or via the hamburger menu only if you are viewing the app as a developer.
I’ve just tried this. I have a function that is decorated with @st.experimental_singleton
and yet I get the error AttributeError: 'function' object has no attribute 'clear'
Version: 1.2.0
Hi @Ollie
This method did not exist in version 1.2.0 of Streamlit. It was added in version 1.4.0. To use the clear method on memo and singleton, and to use all the latest features, upgrade to the latest version of Streamlit:
pip install --upgrade streamlit
Best,
Snehan