I have user case where dashboard base data gets updated in every 1 hour. For good response time I have used cache before data loading function. How I can make cache clear after say 1 hour so that user will see the refreshed data on dashboard.
@st.experimental_memo() has a ttl parameter that is used to specify the maximum number of seconds to keep an entry in the cache.
You can expire the cache entries after an hour by setting ttl to 3600, like so:
import streamlit as st
# Expire the cache every 1 hour.
_CACHE_EXPIRY = 1 * 60 * 60
@st.experimental_memo(ttl=_CACHE_EXPIRY)
def load_data():
# Perform and cache expensive data loading
# Cache expires after ttl
return data