mirror of
https://github.com/amark/gun.git
synced 2025-10-14 00:59:35 +00:00
Update gun.js
This commit is contained in:
parent
c5f7b6283b
commit
69d1e81fc9
12
gun.js
12
gun.js
@ -1027,25 +1027,26 @@
|
|||||||
return Gun.obj.has(this.cache, id);
|
return Gun.obj.has(this.cache, id);
|
||||||
}
|
}
|
||||||
Dedup.prototype.gc = function(){
|
Dedup.prototype.gc = function(){
|
||||||
|
var de = this;
|
||||||
var now = Gun.time.is();
|
var now = Gun.time.is();
|
||||||
var oldest = now;
|
var oldest = now;
|
||||||
var maxAge = 5 * 60 * 1000;
|
var maxAge = 5 * 60 * 1000;
|
||||||
// TODO: Gun.scheduler already does this? Reuse that.
|
// TODO: Gun.scheduler already does this? Reuse that.
|
||||||
Gun.obj.map(this.cache, function (time, id) {
|
Gun.obj.map(de.cache, function (time, id) {
|
||||||
oldest = Math.min(now, time);
|
oldest = Math.min(now, time);
|
||||||
|
|
||||||
if ((now - time) < maxAge) {
|
if ((now - time) < maxAge) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this.cache[id];
|
delete de.cache[id];
|
||||||
});
|
});
|
||||||
|
|
||||||
var done = Gun.obj.empty(this.cache);
|
var done = Gun.obj.empty(de.cache);
|
||||||
|
|
||||||
// Disengage GC.
|
// Disengage GC.
|
||||||
if (done) {
|
if (done) {
|
||||||
this.to = null;
|
de.to = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,8 +1057,7 @@
|
|||||||
var nextGC = maxAge - elapsed;
|
var nextGC = maxAge - elapsed;
|
||||||
|
|
||||||
// Schedule the next GC event.
|
// Schedule the next GC event.
|
||||||
var dedup = this;
|
de.to = setTimeout(function(){ de.gc() }, nextGC);
|
||||||
this.to = setTimeout(function(){ dedup.gc() }, nextGC);
|
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
var text = Type.text, text_is = text.is, text_random = text.random;
|
var text = Type.text, text_is = text.is, text_random = text.random;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user