fix: Recovering messages lost with redis cache

This commit is contained in:
Davidson Gomes
2024-04-18 17:31:05 -03:00
parent 234a2c71b5
commit 7449102d95
3 changed files with 6 additions and 111 deletions

View File

@@ -151,7 +151,7 @@ export class BaileysStartupService extends WAStartupService {
const cacheConf = this.configService.get<CacheConf>('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) => {

View File

@@ -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() {