Alteração para deletar tickets quando os contatos são deletado do cache
parent
fc7d51a04f
commit
a59784d18e
|
@ -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!`)
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue