Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis implement the touch method?

This is important to underdstand for configuration purposes.

If it does implement the touch method than I can safely set resave to false.

session({
  // blah blah
  resave: false
});

How would I go about looking into this as it is not readily available information on the docs page.

I did find this but I think it is a different touch()

https://redis.io/commands/touch

like image 502
jennifer Avatar asked Jun 16 '26 18:06

jennifer


1 Answers

Yes, the redis connector for express-session implements touch. If you look at the relevant portion of the source for the connect-redis module (which is how redis supports express-session), you will find that it does implement the touch method unless an option is passed to disable it.

Here's the relevant source:

touch(sid, sess, cb = noop) {
  if (this.disableTouch) return cb()

  let key = this.prefix + sid
  this.client.expire(key, this._getTTL(sess), (err, ret) => {
    if (err) return cb(err)
    if (ret !== 1) return cb(null, 'EXPIRED')
    cb(null, 'OK')
  })
}
like image 125
jfriend00 Avatar answered Jun 19 '26 18:06

jfriend00