diff --git a/nullboard.html b/nullboard.html
index cea4746..55008ee 100644
--- a/nullboard.html
+++ b/nullboard.html
@@ -1398,7 +1398,7 @@
try
{
this.deltas.popEach((key) => {
- console.log("syncing to replicas: " + key);
+ console.log("syncing: " + key);
this.replicate(key);
});
}
@@ -1429,14 +1429,20 @@
replicate(key)
{
var value = this.cache().get(key);
+ this.replicateOne(this.primary(), key, value);
this.replicas().forEach((database) => {
- if (value)
- database.set(key, value);
- else
- database.del(key, value);
+ this.replicateOne(database, key, value);
});
}
+ replicateOne(database, key, value)
+ {
+ if (value)
+ database.set(key, value);
+ else
+ database.del(key);
+ }
+
get(key)
{
return this.cache().get(key);
@@ -1444,11 +1450,12 @@
set(key, value)
{
- this.primary().set(key, value);
this.deltas.push(key);
try
{
- this.replicas().forEach((database) => {
+ this.cache().set(key, value);
+ this.primary().set(key, value);
+ this.replicas().slice(1).forEach((database) => {
database.set(key, value);
});
this.deltas.pop(key);
@@ -1461,11 +1468,12 @@
del(key)
{
- this.primary().del(key);
this.deltas.push(key);
try
{
- this.replicas().forEach((database) => {
+ this.cache().del(key);
+ this.primary().del(key);
+ this.replicas().slice(1).forEach((database) => {
database.del(key);
});
this.deltas.pop(key);