This reverts commit d294a74aad.
This commit is contained in:
1 parent
bdf94c7f48
commit
6272c881c8
39 files changed
+240
-952
No files matched your search
@@ -2,21 +2,15 @@ import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
import type { AppFlags } from "../config";
|
||||
|
||||
// This is a temporary cache to avoid hitting the database on every lambda invocation
|
||||
let TEMP_CACHE: AppFlags | null = null;
|
||||
|
||||
export async function getFeatureFlagMap(prisma: PrismaClient) {
|
||||
// If we've already fetched the flags, return them
|
||||
if (TEMP_CACHE) return TEMP_CACHE;
|
||||
const flags = await prisma.feature.findMany({
|
||||
orderBy: { slug: "asc" },
|
||||
cacheStrategy: { swr: 300, ttl: 300 },
|
||||
});
|
||||
TEMP_CACHE = flags.reduce((acc, flag) => {
|
||||
return flags.reduce((acc, flag) => {
|
||||
acc[flag.slug as keyof AppFlags] = flag.enabled;
|
||||
return acc;
|
||||
}, {} as AppFlags);
|
||||
return TEMP_CACHE;
|
||||
}, {} as Partial<AppFlags>);
|
||||
}
|
||||
|
||||
interface CacheEntry {
|
||||
|
||||
Reference in new issue
Block a user