[Session Store QBit] - Initial Work #384
KofTwentyTwo
announced in
Daily Build Log
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Been working on something I've needed for a while now - pluggable session storage for QQQ.
The backstory: we've had a few projects where we needed to run multiple instances behind a load balancer, and sessions were a pain point. User logs in, hits instance A, session lives in memory there. Next request goes to instance B, and they're logged out. Classic problem.
So I built a QBit for it. Three providers out of the box:
The Redis one was interesting to build. Jedis makes it pretty straightforward, but I wanted to optimize for the common case - load a session and reset its TTL in one shot. Redis 6.2 added
GETEXwhich does exactly that atomically. Older versions fall back to GET + EXPIRE.Usage is simple:
The QBit registers itself with the new
QSessionStoreRegistryin core, so authentication just picks it up automatically. No changes needed to your auth code.One thing I'm happy with architecturally - this follows the pattern we established with other optional modules. Core defines the interface, the QBit provides implementations and registers on startup. Core never knows about Redis or Jedis. Clean separation.
Still need to write more tests (only have InMemory and config tests so far), but the implementation is solid. Been running it locally and it works as expected.
Next up: Testcontainers for Redis integration tests, then probably cut a 0.1.0 release.
Try It
Add to your
pom.xml:Then in your QInstance setup, add the producer before your auth config. That's it - sessions now go to Redis instead of memory.
Repo: QRun-IO/qbit-session-store
Commits:
All reactions