mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
1 Commits
2.13.6
...
fix-negati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bac04587b8 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.13.6",
|
"version": "2.13.5",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -16,13 +16,8 @@ class ResourceCache {
|
|||||||
let clear = false;
|
let clear = false;
|
||||||
Object.entries(this.resourceCache).forEach((entry) => {
|
Object.entries(this.resourceCache).forEach((entry) => {
|
||||||
const [id, updated] = entry;
|
const [id, updated] = entry;
|
||||||
if (!updated.time) {
|
if (new Date().getTime() - updated > this.expires) {
|
||||||
// clear old version cache
|
|
||||||
delete this.resourceCache[id];
|
|
||||||
$.delete(`#${id}`);
|
$.delete(`#${id}`);
|
||||||
clear = true;
|
|
||||||
}
|
|
||||||
if (new Date().getTime() - updated.time > this.expires) {
|
|
||||||
delete this.resourceCache[id];
|
delete this.resourceCache[id];
|
||||||
clear = true;
|
clear = true;
|
||||||
}
|
}
|
||||||
@@ -31,6 +26,9 @@ class ResourceCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
revokeAll() {
|
revokeAll() {
|
||||||
|
Object.keys(this.resourceCache).forEach((id) => {
|
||||||
|
$.delete(`#${id}`);
|
||||||
|
});
|
||||||
this.resourceCache = {};
|
this.resourceCache = {};
|
||||||
this._persist();
|
this._persist();
|
||||||
}
|
}
|
||||||
@@ -40,16 +38,17 @@ class ResourceCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(id) {
|
get(id) {
|
||||||
const updated = this.resourceCache[id] && this.resourceCache[id].time;
|
const updated = this.resourceCache[id];
|
||||||
if (updated && new Date().getTime() - updated <= this.expires) {
|
if (updated && new Date().getTime() - updated <= this.expires) {
|
||||||
return this.resourceCache[id].data;
|
return $.read(`#${id}`);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(id, value) {
|
set(id, value) {
|
||||||
this.resourceCache[id] = { time: new Date().getTime(), data: value }
|
this.resourceCache[id] = new Date().getTime();
|
||||||
this._persist();
|
this._persist();
|
||||||
|
$.write(value, `#${id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,8 @@ class ResourceCache {
|
|||||||
let clear = false;
|
let clear = false;
|
||||||
Object.entries(this.resourceCache).forEach((entry) => {
|
Object.entries(this.resourceCache).forEach((entry) => {
|
||||||
const [id, updated] = entry;
|
const [id, updated] = entry;
|
||||||
if (!updated.time) {
|
if (new Date().getTime() - updated > this.expires) {
|
||||||
// clear old version cache
|
|
||||||
delete this.resourceCache[id];
|
|
||||||
$.delete(`#${id}`);
|
$.delete(`#${id}`);
|
||||||
clear = true;
|
|
||||||
}
|
|
||||||
if (new Date().getTime() - updated.time > this.expires) {
|
|
||||||
delete this.resourceCache[id];
|
delete this.resourceCache[id];
|
||||||
clear = true;
|
clear = true;
|
||||||
}
|
}
|
||||||
@@ -32,6 +27,9 @@ class ResourceCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
revokeAll() {
|
revokeAll() {
|
||||||
|
Object.keys(this.resourceCache).forEach((id) => {
|
||||||
|
$.delete(`#${id}`);
|
||||||
|
});
|
||||||
this.resourceCache = {};
|
this.resourceCache = {};
|
||||||
this._persist();
|
this._persist();
|
||||||
}
|
}
|
||||||
@@ -41,16 +39,17 @@ class ResourceCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(id) {
|
get(id) {
|
||||||
const updated = this.resourceCache[id] && this.resourceCache[id].time;
|
const updated = this.resourceCache[id];
|
||||||
if (updated && new Date().getTime() - updated <= this.expires) {
|
if (updated && new Date().getTime() - updated <= this.expires) {
|
||||||
return this.resourceCache[id].data;
|
return $.read(`#${id}`);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(id, value) {
|
set(id, value) {
|
||||||
this.resourceCache[id] = { time: new Date().getTime(), data: value }
|
this.resourceCache[id] = new Date().getTime();
|
||||||
this._persist();
|
this._persist();
|
||||||
|
$.write(value, `#${id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user