Cleanup ticking intervals
parent
aed986661c
commit
0d6a6c7a8a
|
|
@ -1325,6 +1325,7 @@
|
||||||
this.databases.push(arguments[i]);
|
this.databases.push(arguments[i]);
|
||||||
}
|
}
|
||||||
this.deltas = new Deltas(this.cache());
|
this.deltas = new Deltas(this.cache());
|
||||||
|
this.intervals = [];
|
||||||
this.scheduleSync();
|
this.scheduleSync();
|
||||||
this.syncCacheWithPrimary();
|
this.syncCacheWithPrimary();
|
||||||
}
|
}
|
||||||
|
|
@ -1367,9 +1368,23 @@
|
||||||
|
|
||||||
scheduleSync()
|
scheduleSync()
|
||||||
{
|
{
|
||||||
setInterval(() => { this.syncDeltas(); }, 10 * 1000);
|
this.intervals.push(
|
||||||
setInterval(() => { this.syncCacheWithPrimary(); }, 120 * 1000);
|
setInterval(() => { this.syncDeltas(); }, 10 * 1000)
|
||||||
setInterval(() => { this.syncReplicasWithCache(); }, 123 * 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()
|
syncDeltas()
|
||||||
|
|
@ -3199,6 +3214,13 @@
|
||||||
|
|
||||||
function setGlobalNamespace(namespace)
|
function setGlobalNamespace(namespace)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (globalStorage && globalStorage.close)
|
||||||
|
globalStorage.close();
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
|
||||||
globalStorage = new MultiDatabase(
|
globalStorage = new MultiDatabase(
|
||||||
new NamespacedDatabase(namespace, new HTTPCRUD()),
|
new NamespacedDatabase(namespace, new HTTPCRUD()),
|
||||||
new NamespacedDatabase(namespace, new Local()),
|
new NamespacedDatabase(namespace, new Local()),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue