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.
Can any one help on this?
@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
# Perform and cache expensive data loading
# Cache expires after ttl
Does this help?