Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Session Management with Redis

Hi Friso,

Any chance you could build your own mongo session management for jetty-9.4?  We have totally re-architected sessions and made it much, much cleaner, clearer and easier to implement for different technologies? I really really recommend you go that way if you possibly can.

I'd be interested to know your motivation for rolling-your-own mongo session management? Always keen to know if there is some functionality that we should be providing in the standard jetty release that would be helpful to the greatest number of users ....

Looks to me like you've found some funnies in the mongo code around line 420: seems weird that we remove the attribute, and then call the http session value unbinding listener with a null value. Also undesirable that there is the side-effect of saving the session in doPutOrRemove: if more than 1 attribute had been removed from the session, the first iteration around would promptly write back in the other attributes!  I would remove all of the attributes from the session, remembering their values and then call the http session unbinding listeners but forego calling sesion.save() at all.

For these kind of reasons, I strongly recommend basing your impl of jetty-9.4 instead.

cheers
Jan

On 20 September 2016 at 22:33, Friso Vrolijken <friso.vrolijken@xxxxxxxxxxxxx> wrote:

Hi all,

 

I want to use Redis as a backing for my sessions. I’ve seen https://github.com/Ovea/jetty-session-redis, but the five years since any commit doesn’t inspire much confidence. I’ve also seen https://dev.eclipse.org/mhonarc/lists/jetty-dev/msg02086.html, but was unable to find the fruits of Denis’ labour.

 

So I’m currently making a NoSqlSessionManager extension based on Redis. For this I’m looking at the Mongo implementation and trying to stay close to it. Doing that I struck some code I don’t understand. Hopefully somebody here can enlighten me?

 

In org.eclipse.jetty.nosql.mongodb.MongoSessionManager.refresh(NoSqlSession, Object), which as I understand exists to update a session in memory from a session on disk, session.doPutOrRemove(attr,value) is called (l. 406). If the manager’s savePeriod is -2, that results in a org.eclipse.jetty.nosql.NoSqlSession.save(boolean), which is used to update a session on disk from memory. This does not look right to me, but I might (very well) be mistaken. Any clues?

 

A little further on in the same method (l. 420) this sequence is called:

                        session.doPutOrRemove(str,null);

                        session.unbindValue(str,session.getAttribute(str));

I think the second call is equivalent to session.unbindValue(str, session.getAttribute(str));, but I’m not sure that that is what the authors meant. Can I do that or should it be:

                        Object o = session.getAttribute(str);

                        session.doPutOrRemove(str,null); // might also result in a save

                        session.unbindValue(str,o);

 

Any help is appreciated,

 

Groeten,

 

Friso

 


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


Back to the top