Ajuste comentario cache de departamento

This commit is contained in:
JurTI-BR 2025-03-14 11:04:20 -03:00
parent b43af08d04
commit 6c324df9e9
2 changed files with 2 additions and 3 deletions

View File

@ -672,6 +672,7 @@ export class OrderService {
numeroSeq = numeroSeq + 1;
}
// execute some operations on this transaction:
await queryRunner.manager
.createQueryBuilder()
.insert()

View File

@ -1123,10 +1123,9 @@ export class SalesService {
async getDepartments(): Promise<Esvdepartamento[]> {
const cacheKey = 'departments';
const lockKey = 'departments_lock';
const lockTimeout = 30; // lock expira em 30 segundos
const lockTimeout = 30;
try {
// Tenta recuperar os departamentos do cache
const cachedDepartments = await this.redisClient.get(cacheKey);
if (cachedDepartments) {
console.log('Buscando departamentos no Redis');
@ -1134,7 +1133,6 @@ export class SalesService {
}
} catch (err) {
console.error('Erro ao acessar o Redis (cache):', err);
// Se o Redis falhar, a execução continua para consultar o banco
}
const lockValue = Date.now() + lockTimeout * 1000 + 1;
const acquiredLock = await this.redisClient.set(lockKey, lockValue, 'NX', 'EX', lockTimeout);