Skip to content

Instantly share code, notes, and snippets.

@diversario
Created June 14, 2014 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diversario/2f18d38b8e287c0809ea to your computer and use it in GitHub Desktop.
Save diversario/2f18d38b8e287c0809ea to your computer and use it in GitHub Desktop.
cm replset test
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)
@diversario
Copy link
Author

➜  connect-mongostore git:(fix/replica-set-timeouts) ✗ curl localhost:8080 -H 'cookie:connect.sid=s%3AV3FsPv2x4aPF7gZ9gZj6WSlx.xLWPwh%2BkSlKgvvlylqs216qOnoiIWDjbtEdv2jJYSTo;'
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"time":1402780906254,"val":6}%
➜  connect-mongostore git:(fix/replica-set-timeouts) ✗ curl localhost:8080 -H 'cookie:connect.sid=s%3AV3FsPv2x4aPF7gZ9gZj6WSlx.xLWPwh%2BkSlKgvvlylqs216qOnoiIWDjbtEdv2jJYSTo;'
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"time":1402780907545,"val":7}%
➜  connect-mongostore git:(fix/replica-set-timeouts) ✗ curl localhost:8080 -H 'cookie:connect.sid=s%3AV3FsPv2x4aPF7gZ9gZj6WSlx.xLWPwh%2BkSlKgvvlylqs216qOnoiIWDjbtEdv2jJYSTo;'
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"time":1402780908082,"val":8}%
➜  connect-mongostore git:(fix/replica-set-timeouts) ✗ curl localhost:8080 -H 'cookie:connect.sid=s%3AV3FsPv2x4aPF7gZ9gZj6WSlx.xLWPwh%2BkSlKgvvlylqs216qOnoiIWDjbtEdv2jJYSTo;'
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"time":1402780908576,"val":9
➜  connect-mongostore git:(fix/replica-set-timeouts) ✗ curl localhost:8080 -H 'cookie:connect.sid=s%3AV3FsPv2x4aPF7gZ9gZj6WSlx.xLWPwh%2BkSlKgvvlylqs216qOnoiIWDjbtEdv2jJYSTo;'
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"time":1402780909026,"val":10}%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment