Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of Redis JSON #421

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add support of Redis JSON #421

wants to merge 4 commits into from

Conversation

otchilin
Copy link

Hi,

As Redis is now supporting JSON, it will be great to also store the session data directly in this format.
This will allows for example to create indexes and find sessions easily against some details as user id or whatever you want. And this is much more optimized than SCAN/MGET over a prefix.

So I propose a small enhancement to add this option (useRedisJson) which is disabled by default to keep standard behavior if not configured.

I've also reworked the build workflow to run test over redis-stack-server under Ubuntu 20.04 which support it via the redis repo.

Hope it will help...

Regards,

@wavded
Copy link
Collaborator

wavded commented Feb 27, 2025

Hey @otchilin, thanks for working on this and bringing to my attention. Do you have resources that explains the benefits of this approach? Maintaining this project now for multiple years and being a user for many before that, I haven't seen any real issues with the storage mechanism in place. I get it is a neat feature that does have benefits but not seeing its benefits for this project yet. Is this widely available? Why did you have to switch to redis-stack-server to test it?

@otchilin
Copy link
Author

Hi @wavded,
Thanks for answer. There is no problem with current storage 👍
Personally, I thought about it when I said to myself that it would be good to have a mechanism in my implementation to kill all the sessions of a given user, for security reason for example...

And since I don't have a reference to the sessions, I would have to search in all the existing sessions those where I find the corresponding user id.
This search through Redis is not very optimized especially if there are a lot of entries.
On the other hand, with the Redis plugin it is possible to have an index and therefore to be much more efficient.

And then, it seems natural to store JSON objects in a storage that supports this format 😉

Concerning the test, I've introduced redis stack server because it supports the json plugin and it's necessary to test the new behavior.

So nothing revolutionary but a little plus for those who would like to take advantage of the power of the Redis JSON plugin.
Of course I understand that it complicates the processing and that it could harm the robustness.

@wavded
Copy link
Collaborator

wavded commented Feb 28, 2025

Thanks for the explanation. We do have the all and ids methods that are used currently if you wanted to search through all the sessions for something. Not as fast as a direct JSON query but are usually used in debugging scenarios anyway.

My gut is to keep this PR around and the concept out there as a possibility and see if the need grows/more use cases come out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants