使用 session-mongodb 存储session 时,默认会产生5条数据库链接
Mon Jul 01 15:43:50.377 [initandlisten] connection accepted from 127.0.0.1:37821
#1 (1 connection now open)
Mon Jul 01 15:43:50.385 [initandlisten] connection accepted from 127.0.0.1:37822
#2 (2 connections now open)
Mon Jul 01 15:43:50.385 [initandlisten] connection accepted from 127.0.0.1:37823
#3 (3 connections now open)
Mon Jul 01 15:43:50.385 [initandlisten] connection accepted from 127.0.0.1:37824
#4 (4 connections now open)
Mon Jul 01 15:43:50.393 [initandlisten] connection accepted from 127.0.0.1:37825
#5 (5 connections now open)
Mon Jul 01 15:44:05.612 [initandlisten] connection accepted from 127.0.0.1:37828
#6 (6 connections now open)
Mon Jul 01 15:44:05.627 [conn6] end connection 127.0.0.1:37828 (5 connections no
w open)
其实应该是一条链接的,应该怎么做啊 app.js配置
var MongoStore = require('session-mongoose')(express);
var settings = require('./Settings');
var sessionStore = new MongoStore({
db:settings.db
},function(){
console.log('connect mongodb success...');
});
app.use(express.session({
secret:settings.db,
store:sessionStore,
cookie:{
maxAge:new Date(Date.now()+1000*60*60)
}
}));