From 9e22e8be586addade3abaac520536175cda99fd4 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 28 Sep 2021 09:30:45 +0200 Subject: [PATCH] perf(core): Use request cache for hot-path tax rate calculation --- .../core/src/service/services/product-variant.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/service/services/product-variant.service.ts b/packages/core/src/service/services/product-variant.service.ts index a5baf7e190..6262e81562 100644 --- a/packages/core/src/service/services/product-variant.service.ts +++ b/packages/core/src/service/services/product-variant.service.ts @@ -592,10 +592,10 @@ export class ProductVariantService { if (!activeTaxZone) { throw new InternalServerError(`error.no-active-tax-zone`); } - const applicableTaxRate = await this.taxRateService.getApplicableTaxRate( + const applicableTaxRate = await this.requestCache.get( ctx, - activeTaxZone, - variant.taxCategory, + `applicableTaxRate-${activeTaxZone.id}-${variant.taxCategory.id}`, + () => this.taxRateService.getApplicableTaxRate(ctx, activeTaxZone, variant.taxCategory), ); const { productVariantPriceCalculationStrategy } = this.configService.catalogOptions;