diff --git a/lib/persistence.js b/lib/persistence.js index a7fe72d..32d8368 100644 --- a/lib/persistence.js +++ b/lib/persistence.js @@ -155,14 +155,16 @@ Persistence.prototype.compactDatafile = function () { * @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds */ 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.autocompactionIntervalId = setInterval(function () { self.compactDatafile(); - }, interval); + }, realInterval); };