Merge pull request #141 from b1rdex/patch-1

fixed setAutocompactionInterval interval arg
pull/2/head
Louis Chatriot 11 years ago
commit c912d21594
  1. 8
      lib/persistence.js

@ -155,14 +155,16 @@ Persistence.prototype.compactDatafile = function () {
* @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds * @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds
*/ */
Persistence.prototype.setAutocompactionInterval = function (interval) { Persistence.prototype.setAutocompactionInterval = function (interval) {
var self = this; var self = this
, minInterval = 5000
, realInterval = Math.max(interval||0, minInterval)
;
if (interval < 5000) { interval = 5000; }
this.stopAutocompaction(); this.stopAutocompaction();
this.autocompactionIntervalId = setInterval(function () { this.autocompactionIntervalId = setInterval(function () {
self.compactDatafile(); self.compactDatafile();
}, interval); }, realInterval);
}; };

Loading…
Cancel
Save