From 45095cfac0c4d563ad2dd913f7fa9d445264588f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:12:52 +0100 Subject: [PATCH] Feature/expire cache entries immediately in case of errors in portfolio snapshot calculation (#4099) * Expire cache entries immediately in case of errors * Update changelog --- CHANGELOG.md | 1 + .../queues/portfolio-snapshot/portfolio-snapshot.processor.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba5bf3a1..fcefd5644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved the labels of the assistant +- Improved the caching of the portfolio snapshot in the portfolio calculator by expiring cache entries immediately in case of errors - Extracted the historical market data editor to a reusable component ## 2.125.0 - 2024-11-30 diff --git a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts index a5a9a37e0..72e2a7ce3 100644 --- a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts +++ b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts @@ -86,7 +86,9 @@ export class PortfolioSnapshotProcessor { const expiration = addMilliseconds( new Date(), - this.configurationService.get('CACHE_QUOTES_TTL') + snapshot.errors.length === 0 + ? this.configurationService.get('CACHE_QUOTES_TTL') + : 0 ); this.redisCacheService.set(