Clear specified st.cache_data

Is there any method to clear specific cache?

something like this

def reset_all():
st.cache_data.clear()

@st.cache_data()
def A
@st.cache_data()
def B

num = st.slider(‘Choose number’, min_value=2, max_value=20, step=1, on_change=reset_all)
#I want to reset X without clear the A & B.

@st.cache_data()
def X

There is an example in the documentation:

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.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.