A cached function’s cache can be procedurally cleared:
import streamlit as st
@st.cache_data
def fetch_and_clean_data(_db_connection, num_rows):
# Fetch data from _db_connection here, and then clean it up.
return data
fetch_and_clean_data.clear()
# Clear all cached entries for this function.