sessionstore
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -39,2 +39,3 @@ 'use strict'; | ||
collectionName: 'sessions', | ||
// heartbeat: 60 * 1000, | ||
ttl: 60 * 60 * 24 * 14 // 14 days | ||
@@ -86,2 +87,3 @@ }; | ||
self.emit('disconnect'); | ||
self.stopHeartbeat(); | ||
}); | ||
@@ -102,2 +104,6 @@ | ||
self.emit('connect'); | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
} | ||
@@ -119,3 +125,34 @@ if (callback) callback(err, self); | ||
stopHeartbeat: function () { | ||
if (this.heartbeatInterval) { | ||
clearInterval(this.heartbeatInterval); | ||
delete this.heartbeatInterval; | ||
} | ||
}, | ||
startHeartbeat: function () { | ||
var self = this; | ||
var gracePeriod = Math.round(this.options.heartbeat / 2); | ||
this.heartbeatInterval = setInterval(function () { | ||
var graceTimer = setTimeout(function () { | ||
if (self.heartbeatInterval) { | ||
console.error((new Error ('Heartbeat timeouted after ' + gracePeriod + 'ms')).stack); | ||
self.db.close(function () {}); | ||
} | ||
}, gracePeriod); | ||
self.db.command({ ping: 1 }, function (err) { | ||
if (graceTimer) clearTimeout(graceTimer); | ||
if (err) { | ||
console.error(err.stack || err); | ||
self.db.close(function () {}); | ||
} | ||
}); | ||
}, this.options.heartbeat); | ||
}, | ||
disconnect: function (callback) { | ||
this.stopHeartbeat(); | ||
if (!this.db || !this.isConnected) { | ||
@@ -122,0 +159,0 @@ if (callback) callback(null); |
{ | ||
"author": "adrai", | ||
"name": "sessionstore", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"private": false, | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"async": "1.4.2", | ||
"async": "1.5.0", | ||
"jsondate": "0.0.1", | ||
@@ -23,3 +23,3 @@ "lodash": "3.10.1", | ||
"cradle": ">=0.2.7", | ||
"elasticsearch": ">=5.0.0", | ||
"elasticsearch": "8.x.x", | ||
"eslint": ">=1.0.0", | ||
@@ -32,3 +32,3 @@ "expect.js": ">= 0.1.2", | ||
"mongodb": ">= 1.x", | ||
"redis": ">= 0.10.1", | ||
"redis": "2.3.x >= 0.10.1", | ||
"tingodb": ">= 0.0.1" | ||
@@ -35,0 +35,0 @@ }, |
@@ -0,1 +1,4 @@ | ||
### [v1.2.8](https://github.com/adrai/sessionstore/compare/v1.2.7...v1.2.8) | ||
- mongodb: added optional heartbeat | ||
### [v1.2.7](https://github.com/adrai/sessionstore/compare/v1.2.6...v1.2.7) | ||
@@ -2,0 +5,0 @@ - couchdb: fixed undefined is not function issue for expires [#28](https://github.com/adrai/sessionstore/issues/28) thanks to [priyanknarvekar](https://github.com/priyanknarvekar) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41488
1064
+ Addedasync@1.5.0(transitive)
- Removedasync@1.4.2(transitive)
Updatedasync@1.5.0