mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-17 04:32:53 -06:00
fix: Adjusts in redis for save instances
This commit is contained in:
parent
4ed1335f89
commit
61bd5b3484
@ -3,11 +3,12 @@
|
|||||||
### Fixed
|
### Fixed
|
||||||
* Revert fix audio encoding
|
* Revert fix audio encoding
|
||||||
* Recovering messages lost with redis cache
|
* Recovering messages lost with redis cache
|
||||||
|
* Adjusts in redis for save instances
|
||||||
* Adjusts in proxy
|
* Adjusts in proxy
|
||||||
* Revert pull request #523
|
* Revert pull request #523
|
||||||
* Added instance name on logs
|
* Added instance name on logs
|
||||||
* Added support for Spanish
|
* Added support for Spanish
|
||||||
* Fix error: invalid operator. The allowed operators for identifier are equal_to,not_equal_to
|
* Fix error: invalid operator. The allowed operators for identifier are equal_to,not_equal_to in chatwoot
|
||||||
|
|
||||||
# 1.7.2 (2024-04-12 17:31)
|
# 1.7.2 (2024-04-12 17:31)
|
||||||
|
|
||||||
|
@ -33,7 +33,10 @@ CLEAN_STORE_CHATS=true
|
|||||||
|
|
||||||
# Permanent data storage
|
# Permanent data storage
|
||||||
DATABASE_ENABLED=false
|
DATABASE_ENABLED=false
|
||||||
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
|
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin &
|
||||||
|
readPreference=primary &
|
||||||
|
ssl=false &
|
||||||
|
directConnection=true
|
||||||
DATABASE_CONNECTION_DB_PREFIX_NAME=evdocker
|
DATABASE_CONNECTION_DB_PREFIX_NAME=evdocker
|
||||||
|
|
||||||
# Choose the data you want to save in the application's database or store
|
# Choose the data you want to save in the application's database or store
|
||||||
@ -43,10 +46,6 @@ DATABASE_SAVE_MESSAGE_UPDATE=false
|
|||||||
DATABASE_SAVE_DATA_CONTACTS=false
|
DATABASE_SAVE_DATA_CONTACTS=false
|
||||||
DATABASE_SAVE_DATA_CHATS=false
|
DATABASE_SAVE_DATA_CHATS=false
|
||||||
|
|
||||||
REDIS_ENABLED=false
|
|
||||||
REDIS_URI=redis://redis:6379
|
|
||||||
REDIS_PREFIX_KEY=evdocker
|
|
||||||
|
|
||||||
RABBITMQ_ENABLED=false
|
RABBITMQ_ENABLED=false
|
||||||
RABBITMQ_RABBITMQ_MODE=global
|
RABBITMQ_RABBITMQ_MODE=global
|
||||||
RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||||
@ -129,6 +128,14 @@ CHATWOOT_MESSAGE_READ=false # false | true
|
|||||||
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgres://user:password@hostname:port/dbname
|
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgres://user:password@hostname:port/dbname
|
||||||
CHATWOOT_IMPORT_DATABASE_PLACEHOLDER_MEDIA_MESSAGE=true
|
CHATWOOT_IMPORT_DATABASE_PLACEHOLDER_MEDIA_MESSAGE=true
|
||||||
|
|
||||||
|
CACHE_REDIS_ENABLED=false
|
||||||
|
CACHE_REDIS_URI=redis://redis:6379
|
||||||
|
CACHE_REDIS_PREFIX_KEY=evolution
|
||||||
|
CACHE_REDIS_TTL=604800
|
||||||
|
CACHE_REDIS_SAVE_INSTANCES=false
|
||||||
|
CACHE_LOCAL_ENABLED=false
|
||||||
|
CACHE_LOCAL_TTL=604800
|
||||||
|
|
||||||
# Defines an authentication type for the api
|
# Defines an authentication type for the api
|
||||||
# We recommend using the apikey because it will allow you to use a custom token,
|
# We recommend using the apikey because it will allow you to use a custom token,
|
||||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||||
|
@ -33,7 +33,10 @@ CLEAN_STORE_CHATS=true
|
|||||||
|
|
||||||
# Permanent data storage
|
# Permanent data storage
|
||||||
DATABASE_ENABLED=true
|
DATABASE_ENABLED=true
|
||||||
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
|
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin &
|
||||||
|
readPreference=primary &
|
||||||
|
ssl=false &
|
||||||
|
directConnection=true
|
||||||
DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
|
DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
|
||||||
|
|
||||||
# Choose the data you want to save in the application's database or store
|
# Choose the data you want to save in the application's database or store
|
||||||
@ -43,10 +46,6 @@ DATABASE_SAVE_MESSAGE_UPDATE=false
|
|||||||
DATABASE_SAVE_DATA_CONTACTS=false
|
DATABASE_SAVE_DATA_CONTACTS=false
|
||||||
DATABASE_SAVE_DATA_CHATS=false
|
DATABASE_SAVE_DATA_CHATS=false
|
||||||
|
|
||||||
REDIS_ENABLED=true
|
|
||||||
REDIS_URI=redis://redis:6379
|
|
||||||
REDIS_PREFIX_KEY=evolution
|
|
||||||
|
|
||||||
# Global Webhook Settings
|
# Global Webhook Settings
|
||||||
# Each instance's Webhook URL and events will be requested at the time it is created
|
# Each instance's Webhook URL and events will be requested at the time it is created
|
||||||
## Define a global webhook that will listen for enabled events from all instances
|
## Define a global webhook that will listen for enabled events from all instances
|
||||||
@ -87,6 +86,14 @@ CONFIG_SESSION_PHONE_NAME=chrome
|
|||||||
# Set qrcode display limit
|
# Set qrcode display limit
|
||||||
QRCODE_LIMIT=30
|
QRCODE_LIMIT=30
|
||||||
|
|
||||||
|
CACHE_REDIS_ENABLED=false
|
||||||
|
CACHE_REDIS_URI=redis://redis:6379
|
||||||
|
CACHE_REDIS_PREFIX_KEY=evolution
|
||||||
|
CACHE_REDIS_TTL=604800
|
||||||
|
CACHE_REDIS_SAVE_INSTANCES=false
|
||||||
|
CACHE_LOCAL_ENABLED=false
|
||||||
|
CACHE_LOCAL_TTL=604800
|
||||||
|
|
||||||
# Defines an authentication type for the api
|
# Defines an authentication type for the api
|
||||||
# We recommend using the apikey because it will allow you to use a custom token,
|
# We recommend using the apikey because it will allow you to use a custom token,
|
||||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -58,10 +58,6 @@ ENV DATABASE_SAVE_MESSAGE_UPDATE=false
|
|||||||
ENV DATABASE_SAVE_DATA_CONTACTS=false
|
ENV DATABASE_SAVE_DATA_CONTACTS=false
|
||||||
ENV DATABASE_SAVE_DATA_CHATS=false
|
ENV DATABASE_SAVE_DATA_CHATS=false
|
||||||
|
|
||||||
ENV REDIS_ENABLED=false
|
|
||||||
ENV REDIS_URI=redis://redis:6379
|
|
||||||
ENV REDIS_PREFIX_KEY=evolution
|
|
||||||
|
|
||||||
ENV RABBITMQ_ENABLED=false
|
ENV RABBITMQ_ENABLED=false
|
||||||
ENV RABBITMQ_MODE=global
|
ENV RABBITMQ_MODE=global
|
||||||
ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||||
@ -129,6 +125,14 @@ ENV QRCODE_COLOR=#198754
|
|||||||
|
|
||||||
ENV TYPEBOT_API_VERSION=latest
|
ENV TYPEBOT_API_VERSION=latest
|
||||||
|
|
||||||
|
ENV CACHE_REDIS_ENABLED=false
|
||||||
|
ENV CACHE_REDIS_URI=redis://redis:6379
|
||||||
|
ENV CACHE_REDIS_PREFIX_KEY=evolution
|
||||||
|
ENV CACHE_REDIS_TTL=604800
|
||||||
|
ENV CACHE_REDIS_SAVE_INSTANCES=false
|
||||||
|
ENV CACHE_LOCAL_ENABLED=false
|
||||||
|
ENV CACHE_LOCAL_TTL=604800
|
||||||
|
|
||||||
ENV AUTHENTICATION_TYPE=apikey
|
ENV AUTHENTICATION_TYPE=apikey
|
||||||
|
|
||||||
ENV AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976
|
ENV AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
export interface ICache {
|
export interface ICache {
|
||||||
get(key: string): Promise<any>;
|
get(key: string): Promise<any>;
|
||||||
|
|
||||||
|
hGet(key: string, field: string): Promise<any>;
|
||||||
|
|
||||||
set(key: string, value: any, ttl?: number): void;
|
set(key: string, value: any, ttl?: number): void;
|
||||||
|
|
||||||
|
hSet(key: string, field: string, value: any): Promise<void>;
|
||||||
|
|
||||||
has(key: string): Promise<boolean>;
|
has(key: string): Promise<boolean>;
|
||||||
|
|
||||||
keys(appendCriteria?: string): Promise<string[]>;
|
keys(appendCriteria?: string): Promise<string[]>;
|
||||||
|
|
||||||
delete(key: string | string[]): Promise<number>;
|
delete(key: string | string[]): Promise<number>;
|
||||||
|
|
||||||
|
hDelete(key: string, field: string): Promise<any>;
|
||||||
|
|
||||||
deleteAll(appendCriteria?: string): Promise<number>;
|
deleteAll(appendCriteria?: string): Promise<number>;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import { v4 } from 'uuid';
|
|||||||
import { ConfigService, HttpServer, WaBusiness } from '../../config/env.config';
|
import { ConfigService, HttpServer, WaBusiness } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||||
import { RedisCache } from '../../libs/redis.client';
|
|
||||||
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
||||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
||||||
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
||||||
@ -41,7 +40,7 @@ export class InstanceController {
|
|||||||
private readonly typebotService: TypebotService,
|
private readonly typebotService: TypebotService,
|
||||||
private readonly integrationService: IntegrationService,
|
private readonly integrationService: IntegrationService,
|
||||||
private readonly proxyService: ProxyController,
|
private readonly proxyService: ProxyController,
|
||||||
private readonly cache: RedisCache,
|
private readonly cache: CacheService,
|
||||||
private readonly chatwootCache: CacheService,
|
private readonly chatwootCache: CacheService,
|
||||||
private readonly messagesLostCache: CacheService,
|
private readonly messagesLostCache: CacheService,
|
||||||
) {}
|
) {}
|
||||||
|
@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express';
|
|||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { configService, Database, Redis } from '../../config/env.config';
|
import { CacheConf, configService, Database } from '../../config/env.config';
|
||||||
import { INSTANCE_DIR } from '../../config/path.config';
|
import { INSTANCE_DIR } from '../../config/path.config';
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
@ -17,12 +17,13 @@ import { cache, waMonitor } from '../server.module';
|
|||||||
async function getInstance(instanceName: string) {
|
async function getInstance(instanceName: string) {
|
||||||
try {
|
try {
|
||||||
const db = configService.get<Database>('DATABASE');
|
const db = configService.get<Database>('DATABASE');
|
||||||
const redisConf = configService.get<Redis>('REDIS');
|
const cacheConf = configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
const exists = !!waMonitor.waInstances[instanceName];
|
const exists = !!waMonitor.waInstances[instanceName];
|
||||||
|
|
||||||
if (redisConf.ENABLED) {
|
if (cacheConf.REDIS.ENABLED && cacheConf.REDIS.SAVE_INSTANCES) {
|
||||||
const keyExists = await cache.keyExists();
|
const keyExists = await cache.has(instanceName);
|
||||||
|
|
||||||
return exists || keyExists;
|
return exists || keyExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import { configService } from '../config/env.config';
|
|||||||
import { eventEmitter } from '../config/event.config';
|
import { eventEmitter } from '../config/event.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
import { dbserver } from '../libs/db.connect';
|
import { dbserver } from '../libs/db.connect';
|
||||||
import { RedisCache } from '../libs/redis.client';
|
|
||||||
import { ChatController } from './controllers/chat.controller';
|
import { ChatController } from './controllers/chat.controller';
|
||||||
import { GroupController } from './controllers/group.controller';
|
import { GroupController } from './controllers/group.controller';
|
||||||
import { InstanceController } from './controllers/instance.controller';
|
import { InstanceController } from './controllers/instance.controller';
|
||||||
@ -107,7 +106,7 @@ export const repository = new RepositoryBroker(
|
|||||||
dbserver?.getClient(),
|
dbserver?.getClient(),
|
||||||
);
|
);
|
||||||
|
|
||||||
export const cache = new RedisCache();
|
export const cache = new CacheService(new CacheEngine(configService, 'instance').getEngine());
|
||||||
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
||||||
const messagesLostCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
const messagesLostCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { BufferJSON } from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { ICache } from '../abstract/abstract.cache';
|
import { ICache } from '../abstract/abstract.cache';
|
||||||
|
|
||||||
@ -20,6 +22,21 @@ export class CacheService {
|
|||||||
return this.cache.get(key);
|
return this.cache.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async hGet(key: string, field: string) {
|
||||||
|
try {
|
||||||
|
const data = await this.cache.hGet(key, field);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
return JSON.parse(data, BufferJSON.reviver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async set(key: string, value: any) {
|
async set(key: string, value: any) {
|
||||||
if (!this.cache) {
|
if (!this.cache) {
|
||||||
return;
|
return;
|
||||||
@ -28,6 +45,16 @@ export class CacheService {
|
|||||||
this.cache.set(key, value);
|
this.cache.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async hSet(key: string, field: string, value: any) {
|
||||||
|
try {
|
||||||
|
const json = JSON.stringify(value, BufferJSON.replacer);
|
||||||
|
|
||||||
|
await this.cache.hSet(key, field, json);
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async has(key: string) {
|
async has(key: string) {
|
||||||
if (!this.cache) {
|
if (!this.cache) {
|
||||||
return;
|
return;
|
||||||
@ -44,6 +71,16 @@ export class CacheService {
|
|||||||
return this.cache.delete(key);
|
return this.cache.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hDelete(key: string, field: string) {
|
||||||
|
try {
|
||||||
|
await this.cache.hDelete(key, field);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async deleteAll(appendCriteria?: string) {
|
async deleteAll(appendCriteria?: string) {
|
||||||
if (!this.cache) {
|
if (!this.cache) {
|
||||||
return;
|
return;
|
||||||
|
@ -5,11 +5,10 @@ import { Db } from 'mongodb';
|
|||||||
import { Collection } from 'mongoose';
|
import { Collection } from 'mongoose';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { Auth, ConfigService, Database, DelInstance, HttpServer, Redis } from '../../config/env.config';
|
import { Auth, CacheConf, ConfigService, Database, DelInstance, HttpServer } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
||||||
import { NotFoundException } from '../../exceptions';
|
import { NotFoundException } from '../../exceptions';
|
||||||
import { RedisCache } from '../../libs/redis.client';
|
|
||||||
import {
|
import {
|
||||||
AuthModel,
|
AuthModel,
|
||||||
ChamaaiModel,
|
ChamaaiModel,
|
||||||
@ -34,7 +33,7 @@ export class WAMonitoringService {
|
|||||||
private readonly eventEmitter: EventEmitter2,
|
private readonly eventEmitter: EventEmitter2,
|
||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly repository: RepositoryBroker,
|
private readonly repository: RepositoryBroker,
|
||||||
private readonly cache: RedisCache,
|
private readonly cache: CacheService,
|
||||||
private readonly chatwootCache: CacheService,
|
private readonly chatwootCache: CacheService,
|
||||||
private readonly messagesLostCache: CacheService,
|
private readonly messagesLostCache: CacheService,
|
||||||
) {
|
) {
|
||||||
@ -44,7 +43,7 @@ export class WAMonitoringService {
|
|||||||
this.noConnection();
|
this.noConnection();
|
||||||
|
|
||||||
Object.assign(this.db, configService.get<Database>('DATABASE'));
|
Object.assign(this.db, configService.get<Database>('DATABASE'));
|
||||||
Object.assign(this.redis, configService.get<Redis>('REDIS'));
|
Object.assign(this.redis, configService.get<CacheConf>('CACHE'));
|
||||||
|
|
||||||
this.dbInstance = this.db.ENABLED
|
this.dbInstance = this.db.ENABLED
|
||||||
? this.repository.dbServer?.db(this.db.CONNECTION.DB_PREFIX_NAME + '-instances')
|
? this.repository.dbServer?.db(this.db.CONNECTION.DB_PREFIX_NAME + '-instances')
|
||||||
@ -52,7 +51,7 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly db: Partial<Database> = {};
|
private readonly db: Partial<Database> = {};
|
||||||
private readonly redis: Partial<Redis> = {};
|
private readonly redis: Partial<CacheConf> = {};
|
||||||
|
|
||||||
private dbInstance: Db;
|
private dbInstance: Db;
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ export class WAMonitoringService {
|
|||||||
});
|
});
|
||||||
this.logger.verbose('instance files deleted: ' + name);
|
this.logger.verbose('instance files deleted: ' + name);
|
||||||
});
|
});
|
||||||
} else if (!this.redis.ENABLED) {
|
} else if (!this.redis.REDIS.ENABLED && !this.redis.REDIS.SAVE_INSTANCES) {
|
||||||
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
||||||
for await (const dirent of dir) {
|
for await (const dirent of dir) {
|
||||||
if (dirent.isDirectory()) {
|
if (dirent.isDirectory()) {
|
||||||
@ -248,10 +247,9 @@ export class WAMonitoringService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.redis.ENABLED) {
|
if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
||||||
this.logger.verbose('cleaning up instance in redis: ' + instanceName);
|
this.logger.verbose('cleaning up instance in redis: ' + instanceName);
|
||||||
this.cache.reference = instanceName;
|
await this.cache.delete(instanceName);
|
||||||
await this.cache.delAll();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +302,7 @@ export class WAMonitoringService {
|
|||||||
this.logger.verbose('Loading instances');
|
this.logger.verbose('Loading instances');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.redis.ENABLED) {
|
if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
||||||
await this.loadInstancesFromRedis();
|
await this.loadInstancesFromRedis();
|
||||||
} else if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
} else if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
||||||
await this.loadInstancesFromDatabase();
|
await this.loadInstancesFromDatabase();
|
||||||
@ -377,12 +375,11 @@ export class WAMonitoringService {
|
|||||||
|
|
||||||
private async loadInstancesFromRedis() {
|
private async loadInstancesFromRedis() {
|
||||||
this.logger.verbose('Redis enabled');
|
this.logger.verbose('Redis enabled');
|
||||||
await this.cache.connect(this.redis as Redis);
|
const keys = await this.cache.keys();
|
||||||
const keys = await this.cache.getInstanceKeys();
|
|
||||||
|
|
||||||
if (keys?.length > 0) {
|
if (keys?.length > 0) {
|
||||||
this.logger.verbose('Reading instance keys and setting instances');
|
this.logger.verbose('Reading instance keys and setting instances');
|
||||||
await Promise.all(keys.map((k) => this.setInstance(k.split(':')[1])));
|
await Promise.all(keys.map((k) => this.setInstance(k.split(':')[2])));
|
||||||
} else {
|
} else {
|
||||||
this.logger.verbose('No instance keys found');
|
this.logger.verbose('No instance keys found');
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,10 @@ import qrcode, { QRCodeToDataURLOptions } from 'qrcode';
|
|||||||
import qrcodeTerminal from 'qrcode-terminal';
|
import qrcodeTerminal from 'qrcode-terminal';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
|
|
||||||
import { ConfigService, ConfigSessionPhone, Database, Log, QrCode, Redis } from '../../../config/env.config';
|
import { CacheConf, ConfigService, ConfigSessionPhone, Database, Log, QrCode } from '../../../config/env.config';
|
||||||
import { INSTANCE_DIR } from '../../../config/path.config';
|
import { INSTANCE_DIR } from '../../../config/path.config';
|
||||||
import { BadRequestException, InternalServerErrorException, NotFoundException } from '../../../exceptions';
|
import { BadRequestException, InternalServerErrorException, NotFoundException } from '../../../exceptions';
|
||||||
import { dbserver } from '../../../libs/db.connect';
|
import { dbserver } from '../../../libs/db.connect';
|
||||||
import { RedisCache } from '../../../libs/redis.client';
|
|
||||||
import { makeProxyAgent } from '../../../utils/makeProxyAgent';
|
import { makeProxyAgent } from '../../../utils/makeProxyAgent';
|
||||||
import { useMultiFileAuthStateDb } from '../../../utils/use-multi-file-auth-state-db';
|
import { useMultiFileAuthStateDb } from '../../../utils/use-multi-file-auth-state-db';
|
||||||
import { useMultiFileAuthStateRedisDb } from '../../../utils/use-multi-file-auth-state-redis-db';
|
import { useMultiFileAuthStateRedisDb } from '../../../utils/use-multi-file-auth-state-redis-db';
|
||||||
@ -126,7 +125,7 @@ export class BaileysStartupService extends WAStartupService {
|
|||||||
public readonly configService: ConfigService,
|
public readonly configService: ConfigService,
|
||||||
public readonly eventEmitter: EventEmitter2,
|
public readonly eventEmitter: EventEmitter2,
|
||||||
public readonly repository: RepositoryBroker,
|
public readonly repository: RepositoryBroker,
|
||||||
public readonly cache: RedisCache,
|
public readonly cache: CacheService,
|
||||||
public readonly chatwootCache: CacheService,
|
public readonly chatwootCache: CacheService,
|
||||||
public readonly messagesLostCache: CacheService,
|
public readonly messagesLostCache: CacheService,
|
||||||
) {
|
) {
|
||||||
@ -149,6 +148,9 @@ export class BaileysStartupService extends WAStartupService {
|
|||||||
public mobile: boolean;
|
public mobile: boolean;
|
||||||
|
|
||||||
private async recoveringMessages() {
|
private async recoveringMessages() {
|
||||||
|
const cacheConf = this.configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
|
if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
this.logger.info('Recovering messages');
|
this.logger.info('Recovering messages');
|
||||||
this.messagesLostCache.keys().then((keys) => {
|
this.messagesLostCache.keys().then((keys) => {
|
||||||
@ -163,6 +165,7 @@ export class BaileysStartupService extends WAStartupService {
|
|||||||
});
|
});
|
||||||
}, 30000);
|
}, 30000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public get connectionStatus() {
|
public get connectionStatus() {
|
||||||
this.logger.verbose('Getting connection status');
|
this.logger.verbose('Getting connection status');
|
||||||
@ -456,12 +459,11 @@ export class BaileysStartupService extends WAStartupService {
|
|||||||
private async defineAuthState() {
|
private async defineAuthState() {
|
||||||
this.logger.verbose('Defining auth state');
|
this.logger.verbose('Defining auth state');
|
||||||
const db = this.configService.get<Database>('DATABASE');
|
const db = this.configService.get<Database>('DATABASE');
|
||||||
const redis = this.configService.get<Redis>('REDIS');
|
const cache = this.configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
if (redis?.ENABLED) {
|
if (cache?.REDIS.ENABLED && cache?.REDIS.SAVE_INSTANCES) {
|
||||||
this.logger.verbose('Redis enabled');
|
this.logger.info('Redis enabled');
|
||||||
this.cache.reference = this.instance.name;
|
return await useMultiFileAuthStateRedisDb(this.instance.name, this.cache);
|
||||||
return await useMultiFileAuthStateRedisDb(this.cache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db.SAVE_DATA.INSTANCE && db.ENABLED) {
|
if (db.SAVE_DATA.INSTANCE && db.ENABLED) {
|
||||||
|
@ -7,7 +7,6 @@ import { getMIMEType } from 'node-mime-types';
|
|||||||
|
|
||||||
import { ConfigService, Database, WaBusiness } from '../../../config/env.config';
|
import { ConfigService, Database, WaBusiness } from '../../../config/env.config';
|
||||||
import { BadRequestException, InternalServerErrorException } from '../../../exceptions';
|
import { BadRequestException, InternalServerErrorException } from '../../../exceptions';
|
||||||
import { RedisCache } from '../../../libs/redis.client';
|
|
||||||
import { NumberBusiness } from '../../dto/chat.dto';
|
import { NumberBusiness } from '../../dto/chat.dto';
|
||||||
import {
|
import {
|
||||||
ContactMessage,
|
ContactMessage,
|
||||||
@ -34,7 +33,7 @@ export class BusinessStartupService extends WAStartupService {
|
|||||||
public readonly configService: ConfigService,
|
public readonly configService: ConfigService,
|
||||||
public readonly eventEmitter: EventEmitter2,
|
public readonly eventEmitter: EventEmitter2,
|
||||||
public readonly repository: RepositoryBroker,
|
public readonly repository: RepositoryBroker,
|
||||||
public readonly cache: RedisCache,
|
public readonly cache: CacheService,
|
||||||
public readonly chatwootCache: CacheService,
|
public readonly chatwootCache: CacheService,
|
||||||
public readonly messagesLostCache: CacheService,
|
public readonly messagesLostCache: CacheService,
|
||||||
) {
|
) {
|
||||||
|
13
src/cache/localcache.ts
vendored
13
src/cache/localcache.ts
vendored
@ -45,4 +45,17 @@ export class LocalCache implements ICache {
|
|||||||
buildKey(key: string) {
|
buildKey(key: string) {
|
||||||
return `${this.module}:${key}`;
|
return `${this.module}:${key}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hGet() {
|
||||||
|
console.log('hGet not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
async hSet() {
|
||||||
|
console.log('hSet not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
async hDelete() {
|
||||||
|
console.log('hDelete not implemented');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
34
src/cache/rediscache.ts
vendored
34
src/cache/rediscache.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import { BufferJSON } from '@whiskeysockets/baileys';
|
||||||
import { RedisClientType } from 'redis';
|
import { RedisClientType } from 'redis';
|
||||||
|
|
||||||
import { ICache } from '../api/abstract/abstract.cache';
|
import { ICache } from '../api/abstract/abstract.cache';
|
||||||
@ -14,7 +15,6 @@ export class RedisCache implements ICache {
|
|||||||
this.conf = this.configService.get<CacheConf>('CACHE')?.REDIS;
|
this.conf = this.configService.get<CacheConf>('CACHE')?.REDIS;
|
||||||
this.client = redisClient.getConnection();
|
this.client = redisClient.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(key: string): Promise<any> {
|
async get(key: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(await this.client.get(this.buildKey(key)));
|
return JSON.parse(await this.client.get(this.buildKey(key)));
|
||||||
@ -23,6 +23,20 @@ export class RedisCache implements ICache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hGet(key: string, field: string) {
|
||||||
|
try {
|
||||||
|
const data = await this.client.hGet(this.buildKey(key), field);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
return JSON.parse(data, BufferJSON.reviver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async set(key: string, value: any, ttl?: number) {
|
async set(key: string, value: any, ttl?: number) {
|
||||||
try {
|
try {
|
||||||
await this.client.setEx(this.buildKey(key), ttl || this.conf?.TTL, JSON.stringify(value));
|
await this.client.setEx(this.buildKey(key), ttl || this.conf?.TTL, JSON.stringify(value));
|
||||||
@ -31,6 +45,16 @@ export class RedisCache implements ICache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hSet(key: string, field: string, value: any) {
|
||||||
|
try {
|
||||||
|
const json = JSON.stringify(value, BufferJSON.replacer);
|
||||||
|
|
||||||
|
await this.client.hSet(this.buildKey(key), field, json);
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async has(key: string) {
|
async has(key: string) {
|
||||||
try {
|
try {
|
||||||
return (await this.client.exists(this.buildKey(key))) > 0;
|
return (await this.client.exists(this.buildKey(key))) > 0;
|
||||||
@ -47,6 +71,14 @@ export class RedisCache implements ICache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async hDelete(key: string, field: string) {
|
||||||
|
try {
|
||||||
|
return await this.client.hDel(this.buildKey(key), field);
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async deleteAll(appendCriteria?: string) {
|
async deleteAll(appendCriteria?: string) {
|
||||||
try {
|
try {
|
||||||
const keys = await this.keys(appendCriteria);
|
const keys = await this.keys(appendCriteria);
|
||||||
|
@ -63,12 +63,6 @@ export type Database = {
|
|||||||
SAVE_DATA: SaveData;
|
SAVE_DATA: SaveData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Redis = {
|
|
||||||
ENABLED: boolean;
|
|
||||||
URI: string;
|
|
||||||
PREFIX_KEY: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Rabbitmq = {
|
export type Rabbitmq = {
|
||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
MODE: string; // global, single, isolated
|
MODE: string; // global, single, isolated
|
||||||
@ -153,6 +147,7 @@ export type CacheConfRedis = {
|
|||||||
URI: string;
|
URI: string;
|
||||||
PREFIX_KEY: string;
|
PREFIX_KEY: string;
|
||||||
TTL: number;
|
TTL: number;
|
||||||
|
SAVE_INSTANCES: boolean;
|
||||||
};
|
};
|
||||||
export type CacheConfLocal = {
|
export type CacheConfLocal = {
|
||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
@ -186,7 +181,6 @@ export interface Env {
|
|||||||
STORE: StoreConf;
|
STORE: StoreConf;
|
||||||
CLEAN_STORE: CleanStoreConf;
|
CLEAN_STORE: CleanStoreConf;
|
||||||
DATABASE: Database;
|
DATABASE: Database;
|
||||||
REDIS: Redis;
|
|
||||||
RABBITMQ: Rabbitmq;
|
RABBITMQ: Rabbitmq;
|
||||||
SQS: Sqs;
|
SQS: Sqs;
|
||||||
WEBSOCKET: Websocket;
|
WEBSOCKET: Websocket;
|
||||||
@ -280,11 +274,6 @@ export class ConfigService {
|
|||||||
LABELS: process.env?.DATABASE_SAVE_DATA_LABELS === 'true',
|
LABELS: process.env?.DATABASE_SAVE_DATA_LABELS === 'true',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
REDIS: {
|
|
||||||
ENABLED: process.env?.REDIS_ENABLED === 'true',
|
|
||||||
URI: process.env.REDIS_URI || '',
|
|
||||||
PREFIX_KEY: process.env.REDIS_PREFIX_KEY || 'evolution',
|
|
||||||
},
|
|
||||||
RABBITMQ: {
|
RABBITMQ: {
|
||||||
ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
|
ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
|
||||||
MODE: process.env?.RABBITMQ_MODE || 'isolated',
|
MODE: process.env?.RABBITMQ_MODE || 'isolated',
|
||||||
@ -398,6 +387,7 @@ export class ConfigService {
|
|||||||
URI: process.env?.CACHE_REDIS_URI || '',
|
URI: process.env?.CACHE_REDIS_URI || '',
|
||||||
PREFIX_KEY: process.env?.CACHE_REDIS_PREFIX_KEY || 'evolution-cache',
|
PREFIX_KEY: process.env?.CACHE_REDIS_PREFIX_KEY || 'evolution-cache',
|
||||||
TTL: Number.parseInt(process.env?.CACHE_REDIS_TTL) || 604800,
|
TTL: Number.parseInt(process.env?.CACHE_REDIS_TTL) || 604800,
|
||||||
|
SAVE_INSTANCES: process.env?.CACHE_REDIS_SAVE_INSTANCES === 'true',
|
||||||
},
|
},
|
||||||
LOCAL: {
|
LOCAL: {
|
||||||
ENABLED: process.env?.CACHE_LOCAL_ENABLED === 'true',
|
ENABLED: process.env?.CACHE_LOCAL_ENABLED === 'true',
|
||||||
|
@ -77,11 +77,6 @@ DATABASE:
|
|||||||
CONTACTS: false
|
CONTACTS: false
|
||||||
CHATS: false
|
CHATS: false
|
||||||
|
|
||||||
REDIS:
|
|
||||||
ENABLED: false
|
|
||||||
URI: "redis://localhost:6379"
|
|
||||||
PREFIX_KEY: "evolution"
|
|
||||||
|
|
||||||
RABBITMQ:
|
RABBITMQ:
|
||||||
ENABLED: false
|
ENABLED: false
|
||||||
MODE: "global"
|
MODE: "global"
|
||||||
@ -181,8 +176,9 @@ CACHE:
|
|||||||
REDIS:
|
REDIS:
|
||||||
ENABLED: false
|
ENABLED: false
|
||||||
URI: "redis://localhost:6379"
|
URI: "redis://localhost:6379"
|
||||||
PREFIX_KEY: "evolution-cache"
|
PREFIX_KEY: "evolution"
|
||||||
TTL: 604800
|
TTL: 604800
|
||||||
|
SAVE_INSTANCES: false
|
||||||
LOCAL:
|
LOCAL:
|
||||||
ENABLED: false
|
ENABLED: false
|
||||||
TTL: 86400
|
TTL: 86400
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
import { createClient, RedisClientType } from '@redis/client';
|
|
||||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
|
||||||
|
|
||||||
import { Redis } from '../config/env.config';
|
|
||||||
import { Logger } from '../config/logger.config';
|
|
||||||
|
|
||||||
export class RedisCache {
|
|
||||||
private readonly logger = new Logger(RedisCache.name);
|
|
||||||
private client: RedisClientType;
|
|
||||||
private statusConnection = false;
|
|
||||||
private instanceName: string;
|
|
||||||
private redisEnv: Redis;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.logger.verbose('RedisCache instance created');
|
|
||||||
process.on('beforeExit', () => {
|
|
||||||
this.logger.verbose('RedisCache instance destroyed');
|
|
||||||
this.disconnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public set reference(reference: string) {
|
|
||||||
this.logger.verbose('set reference: ' + reference);
|
|
||||||
this.instanceName = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async connect(redisEnv: Redis) {
|
|
||||||
this.logger.verbose('Connecting to Redis...');
|
|
||||||
this.client = createClient({ url: redisEnv.URI });
|
|
||||||
this.client.on('error', (err) => this.logger.error('Redis Client Error ' + err));
|
|
||||||
|
|
||||||
await this.client.connect();
|
|
||||||
this.statusConnection = true;
|
|
||||||
this.redisEnv = redisEnv;
|
|
||||||
this.logger.verbose(`Connected to ${redisEnv.URI}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async disconnect() {
|
|
||||||
if (this.statusConnection) {
|
|
||||||
await this.client.disconnect();
|
|
||||||
this.statusConnection = false;
|
|
||||||
this.logger.verbose('Redis client disconnected');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getInstanceKeys(): Promise<string[]> {
|
|
||||||
const keys: string[] = [];
|
|
||||||
try {
|
|
||||||
this.logger.verbose('Fetching instance keys');
|
|
||||||
for await (const key of this.client.scanIterator({ MATCH: `${this.redisEnv.PREFIX_KEY}:*` })) {
|
|
||||||
keys.push(key);
|
|
||||||
}
|
|
||||||
return keys;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('Error fetching instance keys ' + error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async keyExists(key?: string) {
|
|
||||||
try {
|
|
||||||
const keys = await this.getInstanceKeys();
|
|
||||||
const targetKey = key || this.instanceName;
|
|
||||||
this.logger.verbose('keyExists: ' + targetKey);
|
|
||||||
return keys.includes(targetKey);
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async setData(field: string, data: any) {
|
|
||||||
try {
|
|
||||||
this.logger.verbose('setData: ' + field);
|
|
||||||
const json = JSON.stringify(data, BufferJSON.replacer);
|
|
||||||
await this.client.hSet(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field, json);
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getData(field: string): Promise<any | null> {
|
|
||||||
try {
|
|
||||||
this.logger.verbose('getData: ' + field);
|
|
||||||
const data = await this.client.hGet(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
this.logger.verbose('getData: ' + field + ' success');
|
|
||||||
return JSON.parse(data, BufferJSON.reviver);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.verbose('getData: ' + field + ' not found');
|
|
||||||
return null;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async removeData(field: string): Promise<boolean> {
|
|
||||||
try {
|
|
||||||
this.logger.verbose('removeData: ' + field);
|
|
||||||
await this.client.hDel(this.redisEnv.PREFIX_KEY + ':' + this.instanceName, field);
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async delAll(hash?: string): Promise<boolean> {
|
|
||||||
try {
|
|
||||||
const targetHash = hash || this.redisEnv.PREFIX_KEY + ':' + this.instanceName;
|
|
||||||
this.logger.verbose('instance delAll: ' + targetHash);
|
|
||||||
const result = await this.client.del(targetHash);
|
|
||||||
return !!result;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,10 +6,13 @@ import {
|
|||||||
SignalDataTypeMap,
|
SignalDataTypeMap,
|
||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
|
import { CacheService } from '../api/services/cache.service';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
import { RedisCache } from '../libs/redis.client';
|
|
||||||
|
|
||||||
export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
|
export async function useMultiFileAuthStateRedisDb(
|
||||||
|
instanceName: string,
|
||||||
|
cache: CacheService,
|
||||||
|
): Promise<{
|
||||||
state: AuthenticationState;
|
state: AuthenticationState;
|
||||||
saveCreds: () => Promise<void>;
|
saveCreds: () => Promise<void>;
|
||||||
}> {
|
}> {
|
||||||
@ -17,7 +20,7 @@ export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
|
|||||||
|
|
||||||
const writeData = async (data: any, key: string): Promise<any> => {
|
const writeData = async (data: any, key: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
return await cache.setData(key, data);
|
return await cache.hSet(instanceName, key, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return logger.error({ localError: 'writeData', error });
|
return logger.error({ localError: 'writeData', error });
|
||||||
}
|
}
|
||||||
@ -25,7 +28,7 @@ export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
|
|||||||
|
|
||||||
const readData = async (key: string): Promise<any> => {
|
const readData = async (key: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
return await cache.getData(key);
|
return await cache.hGet(instanceName, key);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({ localError: 'readData', error });
|
logger.error({ localError: 'readData', error });
|
||||||
return;
|
return;
|
||||||
@ -34,7 +37,7 @@ export async function useMultiFileAuthStateRedisDb(cache: RedisCache): Promise<{
|
|||||||
|
|
||||||
const removeData = async (key: string) => {
|
const removeData = async (key: string) => {
|
||||||
try {
|
try {
|
||||||
return await cache.removeData(key);
|
return await cache.hDelete(instanceName, key);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({ readData: 'removeData', error });
|
logger.error({ readData: 'removeData', error });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user