mweibel / connect-session-sequelize

Sequelize SessionStore for Express/Connect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Writing to database on every request

crisward opened this issue · comments

This seems to write to the database on every request.

Could it have a threshold added, so it only updates the database every minute, or a user configurable period, based on the updated_at time?

You're welcome to open a PR with the proposed change.
What's the reason for this request?

I've been trying to optimise an application, the biggest bottleneck tends to be the database, so I've been looking to reduce the number of queries and updates. Selecting and updating the session time on every request seems excessive. On high traffic sites we use Redis, but it'd nice to be able to avoid the extra dependency if we can squeeze a bit more our of this module.

I'll see what I can do about a PR.

I came here looking for this option as well. I don't need millisecond level expiration updates. It tends to do a lot of db writing.

I welcome any PR 👍

It looks like there are some problems with trying to solve this in this library.

You would basically have to do a read in order to know not to do an update, so that isnt going to really help.

This might be something that is better solved at the "connect" or "express-session" library level.

I'm actually not sure why touch() is being called by "express-session" on every request? I cant seem to disable rolling updates in the "express-session" library.

I think the best thing that could be done in this library is to offer an option that would basically disable the touch() method from doing anything. That way the user can force a save() on the session by updating its variables, and not worry about the db being written to every request.

Added PR #70

fixed in #70
Release coming soon

released version 5.2.0 on npm.