Created
June 14, 2014 21:26
-
-
Save diversario/2f18d38b8e287c0809ea to your computer and use it in GitHub Desktop.
cm replset test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var replicaSet = { | |
"collection" : "express_sessions", | |
"stringify": false, | |
"db": { | |
"name" : "sessions", | |
"replicaSetOptions": { | |
rs_name: 'default', | |
w: 2 | |
}, | |
"servers" : [ | |
{ | |
"host" : "localhost", | |
"port" : 49000, | |
"options" : { | |
"autoReconnect" : false, | |
"poolSize" : 200, | |
"socketOptions" : { | |
"timeout" : 0, | |
"noDelay" : true, | |
"keepAlive" : 1, | |
"encoding" : "utf8" | |
} | |
} | |
}, | |
{ | |
"host" : "localhost", | |
"port" : 49001, | |
"options" : { | |
"autoReconnect" : false, | |
"poolSize" : 200, | |
"socketOptions" : { | |
"timeout" : 0, | |
"noDelay" : true, | |
"keepAlive" : 1, | |
"encoding" : "utf8" | |
} | |
} | |
}, | |
{ | |
"host" : "localhost", | |
"port" : 49002, | |
"options" : { | |
"autoReconnect" : false, | |
"poolSize" : 200, | |
"socketOptions" : { | |
"timeout" : 0, | |
"noDelay" : true, | |
"keepAlive" : 1, | |
"encoding" : "utf8" | |
} | |
} | |
} | |
] | |
} | |
} | |
var express = require('express'); | |
var session = require('express-session'); | |
var bp = require('body-parser'); | |
var cp = require('cookie-parser') | |
var MongoStore = require('../')(session); | |
var app = express(); | |
app.use(bp()) | |
app.use(cp()) | |
app.use(session({ | |
secret: 'my secret', | |
store: new MongoStore(replicaSet) | |
})); | |
app.get('/', function function_name (req, res, next) { | |
req.session.time = Date.now() | |
if (!req.session.val) req.session.val = 0 | |
req.session.val++ | |
res.send(req.session) | |
}) | |
app.listen(8080) |
Author
diversario
commented
Jun 14, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment