Added way to autocompact, still undocumented

pull/2/head
Louis Chatriot 12 years ago
parent 6e1f25c516
commit ab9c9c68d2
  1. 24
      lib/persistence.js

@ -102,6 +102,30 @@ Persistence.prototype.persistCachedDatabase = function (cb) {
}; };
/**
* Set automatic compaction every interval ms
* @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds
*/
Persistence.prototype.setAutocompactionInterval = function (interval) {
var self = this;
if (interval < 5000) { interval = 5000; }
this.stopAutocompaction();
this.autocompactionIntervalId = setInterval(function () {
self.db.executor.push({ this: self, fn: self.persistCachedDatabase, arguments: [] });
}, interval);
};
/**
* Stop autocompaction (do nothing if autocompaction was not running)
*/
Persistence.prototype.stopAutocompaction = function () {
if (this.autocompactionIntervalId) { clearInterval(this.autocompactionIntervalId); }
};
/** /**
* Persist new state for the given newDocs (can be insertion, update or removal) * Persist new state for the given newDocs (can be insertion, update or removal)
* Use an append-only format * Use an append-only format

Loading…
Cancel
Save