请教大家一个问题,我在后台有2个mongodb,运用了副本集 那么我在express中 store: new MongoStore({ url: require(’./config’).db })
这个url应该怎么配置呢?
使用connect-mongostore https://github.com/diversario/connect-mongostore
app.use(express.session({ secret: 'my secret', store: new MongoStore(replicaSet) }));
var replicaSet = { "collection" : "express_sessions", "stringify": false, "db": { "name" : "sessions", "servers" : [ { "host" : "localhost", "port" : 27017, "options" : { "autoReconnect" : false, "poolSize" : 200, "socketOptions" : { "timeout" : 0, "noDelay" : true, "keepAlive" : 1, "encoding" : "utf8" } } }, { "host" : "localhost", "port" : 27018, "options" : { "autoReconnect" : false, "poolSize" : 200, "socketOptions" : { "timeout" : 0, "noDelay" : true, "keepAlive" : 1, "encoding" : "utf8" } } }, { "host" : "localhost", "port" : 27019, "options" : { "autoReconnect" : false, "poolSize" : 200, "socketOptions" : { "timeout" : 0, "noDelay" : true, "keepAlive" : 1, "encoding" : "utf8" } } } ] } }
太感谢您了,一会实验一下
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
使用connect-mongostore https://github.com/diversario/connect-mongostore
太感谢您了,一会实验一下