1.0.2 • Published 5 years ago

think-session-redis2 v1.0.2

Weekly downloads
14
License
-
Repository
github
Last release
5 years ago

think-session-redis2

Use think-redis2 to store session for ThinkJS
forked from https://github.com/thinkjs/think-session-redis

Install

npm install think-redis2
npm install think-session-redis2

How to use

config file src/config/adapter.js, add options:

const redisSession = require('think-session-redis2');
exports.session = {
  type: 'redis',
  common: {
    cookie: {
      name: 'NODESESSID',
      maxAge: 24 * 3600 * 1000,
      domain: '',
      path: '/',
      httpOnly: true,
      sameSite: false,
      signed: false,
      overwrite: false
    }
  },
  redis: {
    redisName:"rc1", // => ctx.redis(options.redisName)
    // custom redis key
    redisKey(SESSIONID: string) {
      return "[rc1](b)SESSION" + SESSIONID;
    },
    handle: redisSession,
    maxAge: 3600 * 1000, // session timeout, if not set, session will be persistent.
    autoUpdate: false, // update expired time when get session, default is false
  }
}