From 78dc1c87c87639b54df865c39690a04a7bc7f191 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 20 Oct 2022 14:27:58 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/DbSearcher.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index 43b9aa6..589323b 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -18,7 +18,7 @@ class DbSearcher { this.timer = null; this.closed = false; - db.searchCache = { + this.searchCache = { memCache: new Map(), authorIdsAll: false, }; @@ -71,7 +71,7 @@ class DbSearcher { for (const row of authorRows) authorIds.push(row.id); } else {//все авторы - if (!db.searchCache.authorIdsAll) { + if (!this.searchCache.authorIdsAll) { const authorRows = await db.select({ table: 'author', dirtyIdsOnly: true, @@ -81,9 +81,9 @@ class DbSearcher { authorIds.push(row.id); } - db.searchCache.authorIdsAll = authorIds; + this.searchCache.authorIdsAll = authorIds; } else {//оптимизация - authorIds = db.searchCache.authorIdsAll; + authorIds = this.searchCache.authorIdsAll; } } @@ -198,7 +198,7 @@ class DbSearcher { let result = null; const db = this.db; - const memCache = db.searchCache.memCache; + const memCache = this.searchCache.memCache; if (memCache.has(key)) {//есть в недавних result = memCache.get(key); @@ -238,7 +238,7 @@ class DbSearcher { const db = this.db; - const memCache = db.searchCache.memCache; + const memCache = this.searchCache.memCache; memCache.set(key, value); if (memCache.size > maxMemCacheSize) { @@ -406,6 +406,8 @@ class DbSearcher { await utils.sleep(50); } + this.searchCache = null; + if (this.timer) { clearTimeout(this.timer); this.timer = null;