Does State.Vars store values in the backend or frontend ? #3002
-
Great framework ! Thank you guys ! I would like to store a field of State with large values ( probably a dict of map ( dict[str,str] ) with 100 MB. Is the var is being store in backend ( thus being hold in memory ?) or the var is being stored at frontend ,like the browser ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
And will it be placed inside redis? The default limit on value in Redis is 500MB btw.. |
Beta Was this translation helpful? Give feedback.
-
See this blog post for how Reflex works under the hood. The state vars will be stored on the backend and will take up memory. If you're using Redis then it will be stored there. What's your use case where you need such a large state var? Is this var independent for each user of your app, or would it be possible to use a database to store this information? |
Beta Was this translation helpful? Give feedback.
Yes the state manager is pretty much a dictionary from a user token to their state. If you're using the in-memory state manager then yes the state will be there until the server is killed, but if you use Redis by setting a
redis_url
in therxconfig.py
, as we do in our hosting service, then there is an expiration that will wipe it out.We can add an issue for implementing an expiration for the memory state manager. We couldn't do it on the socket disconnect as then if someone has intermittent connection issues. I made this issue as many of our Docker examples don't use Redis and can lead people to this issue: #3021