diff --git a/nullboard.html b/nullboard.html
index b3ccedc..258587c 100644
--- a/nullboard.html
+++ b/nullboard.html
@@ -1325,6 +1325,7 @@
this.databases.push(arguments[i]);
}
this.deltas = new Deltas(this.cache());
+ this.intervals = [];
this.scheduleSync();
this.syncCacheWithPrimary();
}
@@ -1367,9 +1368,23 @@
scheduleSync()
{
- setInterval(() => { this.syncDeltas(); }, 10 * 1000);
- setInterval(() => { this.syncCacheWithPrimary(); }, 120 * 1000);
- setInterval(() => { this.syncReplicasWithCache(); }, 123 * 1000);
+ this.intervals.push(
+ setInterval(() => { this.syncDeltas(); }, 10 * 1000)
+ );
+ this.intervals.push(
+ setInterval(() => { this.syncCacheWithPrimary(); }, 120 * 1000)
+ );
+ this.intervals.push(
+ setInterval(() => { this.syncReplicasWithCache(); }, 123 * 1000)
+ );
+ }
+
+ close()
+ {
+ this.intervals.forEach((i) => {
+ clearInterval(i);
+ });
+ this.intervals = [];
}
syncDeltas()
@@ -3199,6 +3214,13 @@
function setGlobalNamespace(namespace)
{
+ try
+ {
+ if (globalStorage && globalStorage.close)
+ globalStorage.close();
+ }
+ catch (e) {}
+
globalStorage = new MultiDatabase(
new NamespacedDatabase(namespace, new HTTPCRUD()),
new NamespacedDatabase(namespace, new Local()),