-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
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.