mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-21 03:27:22 -06:00
chore: Update group metadata cache (#GI234)
- Updated the group metadata cache to improve performance. - Added verbose logging for cache updates and requests. - Affected file: `whatsapp.baileys.service.ts`. Please note that this change does not alter the functionality or behavior of the application. It is a maintenance task to optimize cache management.
This commit is contained in:
parent
75922e603b
commit
79cadadcc7
@ -3154,6 +3154,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
private async updateGroupMetadataCache(groupJid: string) {
|
private async updateGroupMetadataCache(groupJid: string) {
|
||||||
try {
|
try {
|
||||||
const meta = await this.client.groupMetadata(groupJid);
|
const meta = await this.client.groupMetadata(groupJid);
|
||||||
|
|
||||||
|
this.logger.verbose(`Updating cache for group: ${groupJid}`);
|
||||||
await groupMetadataCache.set(groupJid, {
|
await groupMetadataCache.set(groupJid, {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
data: meta,
|
data: meta,
|
||||||
@ -3170,6 +3172,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
if (!isJidGroup(groupJid)) return null;
|
if (!isJidGroup(groupJid)) return null;
|
||||||
|
|
||||||
if (await groupMetadataCache.has(groupJid)) {
|
if (await groupMetadataCache.has(groupJid)) {
|
||||||
|
this.logger.verbose(`Cache request for group: ${groupJid}`);
|
||||||
const meta = await groupMetadataCache.get(groupJid);
|
const meta = await groupMetadataCache.get(groupJid);
|
||||||
|
|
||||||
if (Date.now() - meta.timestamp > 3600000) {
|
if (Date.now() - meta.timestamp > 3600000) {
|
||||||
@ -3179,6 +3182,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
return meta.data;
|
return meta.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.verbose(`Cache request for group: ${groupJid} - not found`);
|
||||||
return await this.updateGroupMetadataCache(groupJid);
|
return await this.updateGroupMetadataCache(groupJid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user