From a59784d18e99c344fed3f09925b56caaf31887ba Mon Sep 17 00:00:00 2001 From: adriano Date: Fri, 23 Dec 2022 19:45:18 -0300 Subject: [PATCH] =?UTF-8?q?Altera=C3=A7=C3=A3o=20para=20deletar=20tickets?= =?UTF-8?q?=20quando=20os=20contatos=20s=C3=A3o=20deletado=20do=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/helpers/ContactsCache.ts | 10 +++++++--- backend/src/helpers/TicketCache.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/src/helpers/ContactsCache.ts b/backend/src/helpers/ContactsCache.ts index a14af5d..44de800 100644 --- a/backend/src/helpers/ContactsCache.ts +++ b/backend/src/helpers/ContactsCache.ts @@ -4,7 +4,7 @@ import { type } from 'os' const unflatten = require('flat').unflatten var flatten = require('flat') import ListContactsServiceCache from "../services/ContactServices/ListContactsServiceCache" -import { redisConn } from './TicketCache' +import { deleteTicketsByContactsCache, redisConn } from './TicketCache' const deleteContactsByIdCache = async (id: string | number) => { @@ -18,9 +18,13 @@ const deleteContactsByIdCache = async (id: string | number) => { const contact_cache: any = await redis.hgetall(`contact:${id}`) try { - if (contact_cache && Object.keys(contact_cache).length > 0) { + if (contact_cache && Object.keys(contact_cache).length > 0) { - await redis.del(`contact:${id}`) + console.log('contact_cache["number"]: ',contact_cache['number']) + + await deleteTicketsByContactsCache(contact_cache['number']) + + await redis.del(`contact:${id}`) console.log(`Contacts cache number ${contact_cache['number']} deleted!`) } diff --git a/backend/src/helpers/TicketCache.ts b/backend/src/helpers/TicketCache.ts index 1554683..b09b31d 100644 --- a/backend/src/helpers/TicketCache.ts +++ b/backend/src/helpers/TicketCache.ts @@ -36,9 +36,18 @@ const redisConn = async () => { redis.on('connect', () => { + // console.log('CacheStore - Connection status: connected'); resolve(redis); }) + + redis.on('end', () => { + // console.log('CacheStore - Connection status: disconnected'); + }); + + redis.on('reconnecting', () => { + // console.log('CacheStore - Connection status: reconnecting'); + }); }); return await conn();