redis是否实现触摸方法?

kgsdhlau  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(625)

这对于配置目的的underdstand很重要。
如果它实现了触摸方法,那么我可以安全地将resave设置为 false .

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

我将如何着手研究这一点,因为它不是现成的资料上的文件页。
我确实找到了这个,但我认为它是另一种触摸()
https://redis.io/commands/touch

0ve6wy6x

0ve6wy6x1#

是的,redis connector for express session实现了 touch . 如果您查看connect redis模块源代码的相关部分(redis支持express session),您会发现它确实实现了touch方法,除非传递了一个选项来禁用它。
以下是相关资料来源:

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')
  })
}

相关问题