Alteração para deletar tickets quando os contatos são deletado do cache

pull/21/head
adriano 2022-12-23 19:45:18 -03:00
parent fc7d51a04f
commit a59784d18e
2 changed files with 16 additions and 3 deletions

View File

@ -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) => {
@ -20,6 +20,10 @@ const deleteContactsByIdCache = async (id: string | number) => {
try {
if (contact_cache && Object.keys(contact_cache).length > 0) {
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!`)

View File

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