You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In recent redis backend update it seems like session fields are stored as a individual key value pair where value is a JSON encoded bydefault (default encode/decoder) and are namespaced as sessionid_fieldname.
Methods like Clear uses redis SCAN with count 9999999999 to find all the fields and clear it but this is a bad approach since redis SCAN is a blocking command and in a system with reasonable number of session keys blocking time is considerably high. I have tested this by inserting few million fake session keys in redis and called Clear method which took several seconds to return.
I think the better approach is to use redis hashmap for storing session. Session fields will be individual keys in the map and values are encoded with default encoder. Clear method can just delete the hashmap to clear the session in backend instead of iterating over keys. Performance of GetAll method all will be improved by redis HGETALL command which returns all the keys for given session id.
I can send a PR to address the above issue. Please let me know what you think.
The text was updated successfully, but these errors were encountered:
We used that approach in the previous release, I know the benefits and the downsides. You can create a PR and I can review it, maybe you can do it better with redis, I have years to use redis in my own products or on work.
In recent redis backend update it seems like session fields are stored as a individual key value pair where value is a JSON encoded bydefault (default encode/decoder) and are namespaced as
sessionid_fieldname
.Methods like
Clear
uses redisSCAN
with count 9999999999 to find all the fields and clear it but this is a bad approach since redisSCAN
is a blocking command and in a system with reasonable number of session keys blocking time is considerably high. I have tested this by inserting few million fake session keys in redis and calledClear
method which took several seconds to return.I think the better approach is to use redis hashmap for storing session. Session fields will be individual keys in the map and values are encoded with default encoder.
Clear
method can just delete the hashmap to clear the session in backend instead of iterating over keys. Performance ofGetAll
method all will be improved by redisHGETALL
command which returns all the keys for given session id.I can send a PR to address the above issue. Please let me know what you think.
The text was updated successfully, but these errors were encountered: