From fd02cc44fa756ac46f1debf7187f3cf8766301c2 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Wed, 20 Sep 2023 19:50:28 +0100 Subject: [PATCH] feat: Add 300s accelerate cache to feature flags (#11464) --- packages/features/flags/server/router.ts | 1 + packages/features/flags/server/utils.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/features/flags/server/router.ts b/packages/features/flags/server/router.ts index c70751d662cd69..93de96b4b5a427 100644 --- a/packages/features/flags/server/router.ts +++ b/packages/features/flags/server/router.ts @@ -8,6 +8,7 @@ export const featureFlagRouter = router({ const { prisma } = ctx; return prisma.feature.findMany({ orderBy: { slug: "asc" }, + cacheStrategy: { swr: 300, ttl: 300 }, }); }), map: publicProcedure.query(async ({ ctx }) => { diff --git a/packages/features/flags/server/utils.ts b/packages/features/flags/server/utils.ts index 6ffc090d552e14..8f9e8fe75528d9 100644 --- a/packages/features/flags/server/utils.ts +++ b/packages/features/flags/server/utils.ts @@ -5,6 +5,7 @@ import type { AppFlags } from "../config"; export async function getFeatureFlagMap(prisma: PrismaClient) { const flags = await prisma.feature.findMany({ orderBy: { slug: "asc" }, + cacheStrategy: { swr: 300, ttl: 300 }, }); return flags.reduce((acc, flag) => { acc[flag.slug as keyof AppFlags] = flag.enabled;