From 7449102d95c680afaa2202be9218b4cc38a97807 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Thu, 18 Apr 2024 17:31:05 -0300 Subject: [PATCH] fix: Recovering messages lost with redis cache --- .../whatsapp/whatsapp.baileys.service.ts | 2 +- src/cache/cacheengine.ts | 5 + views/manager-wip.hbs | 110 ------------------ 3 files changed, 6 insertions(+), 111 deletions(-) delete mode 100644 views/manager-wip.hbs diff --git a/src/api/services/whatsapp/whatsapp.baileys.service.ts b/src/api/services/whatsapp/whatsapp.baileys.service.ts index 3990c0e3..d8d856a1 100644 --- a/src/api/services/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/services/whatsapp/whatsapp.baileys.service.ts @@ -151,7 +151,7 @@ export class BaileysStartupService extends WAStartupService { const cacheConf = this.configService.get('CACHE'); if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) { - setTimeout(async () => { + setInterval(async () => { this.logger.info('Recovering messages'); this.messagesLostCache.keys().then((keys) => { keys.forEach(async (key) => { diff --git a/src/cache/cacheengine.ts b/src/cache/cacheengine.ts index 258a98c2..dd3d18f1 100644 --- a/src/cache/cacheengine.ts +++ b/src/cache/cacheengine.ts @@ -1,8 +1,11 @@ import { ICache } from '../api/abstract/abstract.cache'; import { CacheConf, ConfigService } from '../config/env.config'; +import { Logger } from '../config/logger.config'; import { LocalCache } from './localcache'; import { RedisCache } from './rediscache'; +const logger = new Logger('Redis'); + export class CacheEngine { private engine: ICache; @@ -14,6 +17,8 @@ export class CacheEngine { } else if (cacheConf?.LOCAL?.ENABLED) { this.engine = new LocalCache(configService, module); } + + logger.info(`RedisCache initialized for ${module}`); } public getEngine() { diff --git a/views/manager-wip.hbs b/views/manager-wip.hbs deleted file mode 100644 index 59b0cd0f..00000000 --- a/views/manager-wip.hbs +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - Instance Manager - - - -
- - - - - - - - - - - - - - - - {{#each instances}} - - - - - - - {{/each}} - -
Nome da InstânciaStatusAPI KeyAções
{{this.instance.instanceName}}{{this.instance.status}}{{this.instance.apikey}} - - -
-
- - - - - - - - - - - - \ No newline at end of file