Permalink
Browse files

clear reap interval on db disconnect

only works with external db objects right now
  • Loading branch information...
1 parent bd0e07c commit 9d1fd69266c80ac7375cdf24bd61fa3618a4d71a @defunctzombie defunctzombie committed Nov 2, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/connect-mongodb.js
@@ -76,9 +76,13 @@ var MONGOSTORE = module.exports = function MongoStore(options, callback) {
Store.call(this, options);
if (options.reapInterval !== -1) {
- setInterval(function () {
+ var reap_interval = setInterval(function () {
_collection.remove({expires: {'$lte': Date.now()}}, function () { });
}, options.reapInterval || _defaults.reapInterval, this); // _defaults to each minute
+
+ db.on('close', function() {
+ clearInterval(reap_interval);
+ });
}
if (server_config.isConnected()) {

0 comments on commit 9d1fd69

Please sign in to comment.