Работа над новым поиском

This commit is contained in:
Book Pauk
2022-10-30 16:44:51 +07:00
parent c904990eed
commit fba7300131
3 changed files with 31 additions and 25 deletions

View File

@@ -318,8 +318,8 @@ class DbSearcher {
async filterTableIds(tableIds, from, query) {
let result = tableIds;
//т.к. авторы идут списком, то дополнительно фильтруем
if (query.author && query.author !== '*') {
//т.к. авторы у книги идут списком, то дополнительно фильтруем
if (from == 'author' && query.author && query.author !== '*') {
const key = `filter-ids-author-${query.author}`;
let authorIds = await this.getCached(key);
@@ -591,18 +591,24 @@ class DbSearcher {
}
}
//кладем в таблицу
await db.insert({
table: 'query_cache',
replace: true,
rows: [{id: key, value}],
});
//кладем в таблицу асинхронно
(async() => {
try {
await db.insert({
table: 'query_cache',
replace: true,
rows: [{id: key, value}],
});
await db.insert({
table: 'query_time',
replace: true,
rows: [{id: key, time: Date.now()}],
});
await db.insert({
table: 'query_time',
replace: true,
rows: [{id: key, time: Date.now()}],
});
} catch(e) {
console.error(`putCached: ${e.message}`);
}
})();
}
async periodicCleanCache() {