-
-
Notifications
You must be signed in to change notification settings - Fork 12
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 session-store to express #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me, only one small question.
app.use( | ||
session({ | ||
store: new RedisStore({ | ||
client: this.redisClient, | ||
disableTouch: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you disabled touch, i.e that session are kept alive when the user interacts with the service without changing the session in itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Redis, we can store data with a timer, and then later, whenever we interact with that data, Touch will update the timer. Here we aren't setting any timer. We want to store sessions forever. So no need to keep updating it.
It reduces the number of requests to Redis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I understood the documentation
ttl
If the session cookie has a expires date, connect-redis will use it as the TTL.
Otherwise, it will expire the session using the ttl option (default: 86400 seconds or one day).
that it normally expires after 1day. If disableTouch: false
then actions reset the ttl, so that session expire 1 day after the last interaction; otherwise 1 day after creation of the session. Anyway, since maxAge is set rather high, this shouldn't be much of a problem and can easily be changed later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I currently cannot activate redis on heruko (temporary problem with the payment method), I will keep this PR open for now and merge later.
Redis should work now on Azure...so let's merge 🚀 |
#104
This PR adds Redis as a session store for express.