offline support
parent
13fc57eacb
commit
6670a6de6c
|
|
@ -1398,7 +1398,7 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.deltas.popEach((key) => {
|
this.deltas.popEach((key) => {
|
||||||
console.log("syncing to replicas: " + key);
|
console.log("syncing: " + key);
|
||||||
this.replicate(key);
|
this.replicate(key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1429,14 +1429,20 @@
|
||||||
replicate(key)
|
replicate(key)
|
||||||
{
|
{
|
||||||
var value = this.cache().get(key);
|
var value = this.cache().get(key);
|
||||||
|
this.replicateOne(this.primary(), key, value);
|
||||||
this.replicas().forEach((database) => {
|
this.replicas().forEach((database) => {
|
||||||
if (value)
|
this.replicateOne(database, key, value);
|
||||||
database.set(key, value);
|
|
||||||
else
|
|
||||||
database.del(key, value);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
replicateOne(database, key, value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
database.set(key, value);
|
||||||
|
else
|
||||||
|
database.del(key);
|
||||||
|
}
|
||||||
|
|
||||||
get(key)
|
get(key)
|
||||||
{
|
{
|
||||||
return this.cache().get(key);
|
return this.cache().get(key);
|
||||||
|
|
@ -1444,11 +1450,12 @@
|
||||||
|
|
||||||
set(key, value)
|
set(key, value)
|
||||||
{
|
{
|
||||||
this.primary().set(key, value);
|
|
||||||
this.deltas.push(key);
|
this.deltas.push(key);
|
||||||
try
|
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);
|
database.set(key, value);
|
||||||
});
|
});
|
||||||
this.deltas.pop(key);
|
this.deltas.pop(key);
|
||||||
|
|
@ -1461,11 +1468,12 @@
|
||||||
|
|
||||||
del(key)
|
del(key)
|
||||||
{
|
{
|
||||||
this.primary().del(key);
|
|
||||||
this.deltas.push(key);
|
this.deltas.push(key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.replicas().forEach((database) => {
|
this.cache().del(key);
|
||||||
|
this.primary().del(key);
|
||||||
|
this.replicas().slice(1).forEach((database) => {
|
||||||
database.del(key);
|
database.del(key);
|
||||||
});
|
});
|
||||||
this.deltas.pop(key);
|
this.deltas.pop(key);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue