Skip to content

Commit

Permalink
Improved Cache Sized Accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
CMEONE committed Mar 5, 2021
1 parent ff61348 commit 1451918
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class tApp {
static started = false;
static database;
static get version() {
return "v0.4.1";
return "v0.4.2";
}
static configure(params) {
if(params == null) {
Expand Down Expand Up @@ -204,12 +204,14 @@ class tApp {
let keys = Object.keys(cachedData);
let size = 0;
for(let i = 0; i < keys.length; i++) {
size += new Blob([keys[i]]).size;
size += new Blob([cachedData[keys[i]].data]).size;
}
while(size > tApp.config.caching.maxBytes) {
let num = Math.floor(Math.random() * keys.length);
if(num < keys.length) {
let removedPage = await tApp.removeCachedPage(keys[num]);
size -= new Blob([keys[num]]).size;
size -= new Blob([removedPage.data]).size;
}
}
Expand Down

0 comments on commit 1451918

Please sign in to comment.