Open mortensi opened 1 week ago
Hi @mortensi thanks for your input. I have been absent and still need to catch up on some other PRs but this sounds like an interesting proposal.
My first though is possibly offering a 'passthrough mode' where flask-session doesn't do any serialization/deserialization, but only provides session.id and sets and reads cookies. This would then allow the user to operate something like redis-py on the session ids to achieve all of the functionality you have mentioned. I haven't thought too deeply on this but it is likely there would need to be manual use of methods like .should_set_cookie. Flask-session could provide non-shipped boilerplate to this effect in the repo if it is useful. What are your thoughts?
I just noticed that you are with redis so that is great news that you are taking an interest here!
I do see also two other options beyond my suggestion above
Depending on the choice, the overall position of Flask-session may need adjustment. Flask-session currently sits in a strange place where we try to facilitate the easy swap in and out of backends, which is great for users and has been great to consolidate the important logic, but it may not be sustainable long term for paradigm shifts such as this.
I was also eventually hoping to align the core logic and settings with quart-session.
My overarching concern is to keep core logic and settings of flask-session / quart-session within the close watch of the pallets team while being open to somewhat interchangeable backends, how that is achieved is definitely open to interpretation
My secondary concern would just be that we don't reinvent redis-py within flask-session :)
Thanks for your prompt answer, @Lxstr.
Your ideas and scenarios make sense, but I need to determine the best way forward at this time.
Finally, porting the same strategy and work to Quart makes a lot of sense.
We'll take some time to analyze the situation and try to understand what fits the long-term view of the Pallets team. I will post my progress here.
Session management could be improved by modeling it as a hash as Spring does. This would reduce serialization/deserialization overheads and benefit from the latest hash-field expiration improvements in Redis 7.4. I would like to understand how to enhance flask-session to support the hash data model (while keeping backward compatibility with the current string format). So, as a summary, we would like to introduce:
Next Redis 8 version will include search capabilities (already available in the Redis Stack packaging) that can support the scenarios above.
I am willing to contribute, but I would appreciate feedback before starting any actual work on this.