How to clear the cache regularly

Hello,
I have a question.
I would like to create a program to delete all caches once an hour, but I can’t come up with an implementation idea.
If you have an implementation idea, please let me know.
Thanks.

1 Like

Hi @akazdayo, great to see you back on our forums! :raised_hands:

I haven’t tried this personally, but I believe you could use a combination of st.cache_resource.clear() and Python’s time module.

For instance, to clear the cache every hour, you can use Python’s time module to track the elapsed time since the app started. When the elapsed time exceeds one hour, call the st.cache_resource.clear() function to clear the cache and then reset the start time.

Hope that makes sense, and let me know if you need any help building this.

Best,
Charly

1 Like

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