closed #2097 -- NodeBB will prefer using Redis as session store if at all possible

v1.18.x
Julian Lam 10 years ago
parent 20819e3dfd
commit ecea917d11

@ -43,8 +43,14 @@
module.init = function(callback) {
try {
var sessionStore;
mongoClient = require('mongodb').MongoClient;
mongoStore = require('connect-mongo')({session: session});
if (!nconf.get('redis')) {
sessionStore = require('connect-mongo')({session: session});
} else {
sessionStore = require('connect-redis')(session);
}
} catch (err) {
winston.error('Unable to initialize MongoDB! Is MongoDB installed? Error :' + err.message);
process.exit();
@ -60,9 +66,16 @@
module.client = db;
module.sessionStore = new mongoStore({
if (!nconf.get('redis')) {
module.sessionStore = new sessionStore({
db: db
});
} else {
module.sessionStore = new sessionStore({
client: require('./redis').connect(),
ttl: 60 * 60 * 24 * 14
});
}
require('./mongo/main')(db, module);
require('./mongo/hash')(db, module);

Loading…
Cancel
Save