|
|
@ -102,6 +102,14 @@ Persistence.prototype.persistCachedDatabase = function (cb) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Queue a rewrite of the datafile |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Persistence.prototype.compactDatafile = function () { |
|
|
|
|
|
|
|
this.db.executor.push({ this: this, fn: this.persistCachedDatabase, arguments: [] }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set automatic compaction every interval ms |
|
|
|
* Set automatic compaction every interval ms |
|
|
|
* @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds |
|
|
|
* @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds |
|
|
@ -113,7 +121,7 @@ Persistence.prototype.setAutocompactionInterval = function (interval) { |
|
|
|
this.stopAutocompaction(); |
|
|
|
this.stopAutocompaction(); |
|
|
|
|
|
|
|
|
|
|
|
this.autocompactionIntervalId = setInterval(function () { |
|
|
|
this.autocompactionIntervalId = setInterval(function () { |
|
|
|
self.db.executor.push({ this: self, fn: self.persistCachedDatabase, arguments: [] }); |
|
|
|
self.compactDatafile(); |
|
|
|
}, interval); |
|
|
|
}, interval); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|