I'm trying to set up redis-rails sessions with some unique behavior. I need to be able to allow multiple sessions by the same user, and also get all of the sessions owned by a particular user.
I don't want to have to search redis by value since that would result in poor performance. So I was thinking I could prepend the session's key with the user's id, and then do a get query with a wildcard.
It looks like I can add a namespace
option to session_store
, but that's just for namespacing to keep multiple apps from colliding, and won't generate the prefix dynamically.
I've tried monkeypatching Rack's generate_sid
method, but I don't have access to the user resource and its id at that level, so I can change the way it's generated, but it can only be a different random number.