koa-redis 中间键存session 问题
发布于 7 个月前 作者 yujintang 1249 次浏览 来自 问答

环境: Node.js v7.5.0, “koa”: “^2.0.0-alpha.7”,

const session = require(‘koa-session-minimal’); const redisStore = require(‘koa-redis’); app.use(session( store: redisStore({ host: cfg_rds.host, port: cfg_rds.port, db: cfg_rds.db, retry_unfulfilled_commands:true, // retry_strategy: function (options) { // if (options.error && options.error.code === ‘ECONNREFUSED’) { // // End reconnecting on a specific error and flush all commands with a individual error // return new Error(‘The server refused the connection’); // } // if (options.total_retry_time > 1000 * 60 * 60) { // // End reconnecting after a specific timeout and flush all commands with a individual error // return new Error(‘Retry time exhausted’); // } // if (options.times_connected > 10) { // // End reconnecting with built in error // return undefined; // } // // reconnect after // return Math.min(options.attempt * 100, 3000); // } }), cookie: ctx =>({ maxAge: ctx.session.user ? maxAge : 0, signed: true }) ));

运行起来,如果有注释部分,则redis断线后不重新连接,没有注释部分,则服务器会卡顿在redis连接处。求大神解答。

回到顶部