Ajuste comentario cache de departamento
This commit is contained in:
parent
b43af08d04
commit
6c324df9e9
|
|
@ -672,6 +672,7 @@ export class OrderService {
|
|||
numeroSeq = numeroSeq + 1;
|
||||
}
|
||||
|
||||
// execute some operations on this transaction:
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue