skinny-framework / skinny-framework

:monorail: "Scala on Rails" - A full-stack web app framework for rapid development in Scala

Home Page:https://skinny-framework.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

make SkinnySession storage pluggable

DanielJoyce opened this issue · comments

Right now SkinnySession relies on jdbc for persistence. If you want 'immediately' consistent sessions, this requires a db read and or write for each request, for every page using it. Lots of overhead!

It would be nice if SkinnySession was broken apart to provide a pluggable API so I could have a memcached backend, a mongo/redis/etc backed, etc.

For my own project, I plan on refactoring SkinnyFilter and SkinnySession.

Right now, only JDBC implementation is provided but it would be nce to add other backend implementations and switch what to use by specifying it in application.conf (e.g.) skinny.session.backend=memcacched.

skinny.session.jdbc.* things are hidden by skinny.session.SkinnyHttpSession. Just adding new back implementation and adding the above application.conf setting and reading it will be needed.

Seems weird you have to explicitly use skinnySession in your controllers. Since we have ServletContext and even low level access to the servlet sessions, can't we simply just swap out the default session handling with a new one?

If there was a library which provides stable and mostly compatible HttpSession replacement, using it in Skinny apps would be simpler. If you or someone is going to create such a thing, it won't depend on Skinny stack but just Servlet APIs.

It would seem this would be the best hook as opposed to a special session manager.

https://wiki.eclipse.org/Jetty/Howto/Persisting_Sessions

Here, instead of HashSessionManager, we'd create a "MemcacheSessionManager" or whatever, and hook into Jetty.

    ctx.asInstanceOf[org.eclipse.jetty.webapp.WebAppContext].setSessionHandler(mySessionHandler)

I think

Of course, this would only support Jetty. Each webapp server would need its own session handler. I know this is possible because TerraCota offered a distributed session cache for tomcat 6 years ago or so, which provides a similar api...