How to have independent cache in spaces
I want to have a cache for each user doing a task, their particular cache is retained so that if the same user is using the service then, the process is fastened. The cache is then deleted upon  completion.
2024-10-30T10:06:43Z
Maybe it’s done by default in HF Spaces, but do you want to implement some additional cache, something likelru_cache?gradio.appSetting Up A Demo For Maximum PerformanceA Step-by-Step Gradio Tutorial
2024-10-30T10:21:32Z
I think I framed my question incorrectly, the issue is that I wanna have a local variable store the results worked to speed up the process with the same but I found out that local variable isn’t actually exclusive of the person who is using it and hence, doesn’t permit mutual exclusion.
2024-10-30T10:32:00Z
I think it’s basically saved per user instance, except for file-related and special functions and variables like pipelines and environment variables.It may change a bit depending on the settings when Gradio is started, though. Maybe you’re running into some weird bug?
2024-10-30T11:15:02Z
Here’s my implementation: need global otherwise it won’t persist through another function callhuggingface.coTestVariable - a Hugging Face Space by eternalBlissardDiscover amazing ML apps made by the community
2024-10-30T11:40:22Z
I see that global variables are shared.How about using gr.State() or gr.JSON() to manage variables?Or you could use uuid as a key and create a dict and store variables for each user in it.
2024-10-30T13:25:34Z
Thanks a lot! I didn’t know Gradio had States similar to React
2024-10-31T01:26:18Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.