Expose db.persistence.compactDatafile

pull/2/head
Louis Chatriot 12 years ago
parent a26a45174a
commit 9e71dbd9e5
  1. 10
      lib/persistence.js
  2. 2
      package.json

@ -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);
}; };

@ -1,6 +1,6 @@
{ {
"name": "nedb", "name": "nedb",
"version": "0.8.2", "version": "0.8.3",
"author": { "author": {
"name": "tldr.io", "name": "tldr.io",
"email": "hello@tldr.io" "email": "hello@tldr.io"

Loading…
Cancel
Save