Added Prisma Acelerate for Caching

This commit is contained in:
Ahmad 2024-03-17 00:48:01 -04:00
parent 48646e22a7
commit 487605df3e
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
7 changed files with 21 additions and 3 deletions

View file

@ -1,9 +1,11 @@
import { PrismaClient } from '@prisma/client';
import { withAccelerate } from '@prisma/extension-accelerate';
declare global {
var prisma: PrismaClient | undefined;
}
export const db = globalThis.prisma ?? new PrismaClient();
export const db = new PrismaClient().$extends(withAccelerate());
if (process.env.NODE_ENV !== 'production') globalThis.prisma = db;
// if (process.env.NODE_ENV !== 'production') globalThis.prisma = db;
// globalThis.prisma ??

View file

@ -21,6 +21,7 @@ export const checkSubscription = async () => {
stripeCustomerId: true,
stripePriceId: true,
},
cacheStrategy: { ttl: 30, swr: 60 },
});
if (!orgSubscription) {