From c3d2f8aa4002884b3f6c2e7c780c85f6a54a46fd Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 31 Jul 2026 15:14:57 +0200 Subject: [PATCH] Improve performance by caching properties in memory --- apps/api/src/services/property/property.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/property/property.service.ts b/apps/api/src/services/property/property.service.ts index 564ea1604d..acfa5822c9 100644 --- a/apps/api/src/services/property/property.service.ts +++ b/apps/api/src/services/property/property.service.ts @@ -16,7 +16,7 @@ import { PropertyValue } from './interfaces/interfaces'; export class PropertyService { private static readonly CACHE_TTL = ms('1 minute'); - private cachedProperties: Property[]; + private cachedProperties: Promise; private cachedPropertiesExpiresAt: Date; public constructor(private readonly prismaService: PrismaService) {} @@ -88,7 +88,13 @@ export class PropertyService { return this.cachedProperties; } - this.cachedProperties = await this.prismaService.property.findMany(); + this.cachedProperties = this.prismaService.property + .findMany() + .catch((error) => { + this.invalidateCache(); + + throw error; + }); this.cachedPropertiesExpiresAt = addMilliseconds( new Date(),