impl redis cloud
This commit is contained in:
@@ -17,6 +17,10 @@ export class DataConsultService {
|
||||
|
||||
private readonly SELLERS_CACHE_KEY = 'data-consult:sellers';
|
||||
private readonly SELLERS_TTL = 3600; // 1 hora
|
||||
private readonly STORES_TTL = 3600;
|
||||
private readonly BILLINGS_TTL = 3600;
|
||||
private readonly ALL_PRODUCTS_CACHE_KEY = 'data-consult:products:all';
|
||||
private readonly ALL_PRODUCTS_TTL = 600; // 10 minutos (ajustável)
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -59,8 +63,11 @@ export class DataConsultService {
|
||||
async billings(): Promise<BillingDto[]> {
|
||||
this.logger.log('Buscando todos os faturamentos');
|
||||
return this.repository.findBillings();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Obter clientes filtrados por termo de pesquisa
|
||||
* @param filter - Termo de pesquisa para filtrar clientes
|
||||
@@ -95,4 +102,17 @@ export class DataConsultService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async getAllProducts(): Promise<ProductDto[]> {
|
||||
this.logger.log('Buscando produtos com cache Redis...');
|
||||
return getOrSetCache<ProductDto[]>(
|
||||
this.redisClient,
|
||||
this.ALL_PRODUCTS_CACHE_KEY,
|
||||
this.ALL_PRODUCTS_TTL,
|
||||
async () => {
|
||||
this.logger.log('Cache de produtos vazio. Buscando no banco...');
|
||||
return this.repository.findAllProducts();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user