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

@ -15,6 +15,6 @@ Currently, there is no documentation or wiki available but, I do plan to add one
[Privacy Policy](https://tasko-omega.vercel.app/privacy-policy)
[Terms of Service](https://tasko-omega.vercel.app/terms-of-service) *There is no terms of service yet but, one will be added soon*
[Terms of Service](https://tasko-omega.vercel.app/terms-of-service) _There is no terms of service yet but, one will be added soon_
[License](https://github.com/ahmadk953/tasko/blob/main/LICENCE)

View file

@ -41,6 +41,7 @@ const BoardIdLayout = async ({
id: params.boardId,
orgId,
},
cacheStrategy: { ttl: 30, swr: 60 },
});
if (!board) notFound();

View file

@ -25,6 +25,7 @@ export const BoardList = async () => {
orderBy: {
createdAt: 'desc',
},
cacheStrategy: { ttl: 30, swr: 60 },
});
const availableCount = await getAvailableCount();

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) {

12
package-lock.json generated
View file

@ -16,6 +16,7 @@
"@liveblocks/react": "^1.10.4",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@prisma/client": "^5.11.0",
"@prisma/extension-accelerate": "^1.0.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
@ -798,6 +799,17 @@
"integrity": "sha512-WXCuyoymvrS4zLz4wQagSsc3/nE6CHy8znyiMv8RKazKymOMd5o9FP5RGwGHAtgoxd+aB/BWqxuP/Ckfu7/3MA==",
"devOptional": true
},
"node_modules/@prisma/extension-accelerate": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@prisma/extension-accelerate/-/extension-accelerate-1.0.0.tgz",
"integrity": "sha512-5oSpPtKCMfTl/sSXaS/7vBsPqfm+eEVB6/5KPBJITFatDoFcmjx/PIC/T93mHLiHI98xKwosPN59NGXjDDhcFA==",
"engines": {
"node": ">=16"
},
"peerDependencies": {
"@prisma/client": ">=4.16.1"
}
},
"node_modules/@prisma/fetch-engine": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.11.0.tgz",

View file

@ -19,6 +19,7 @@
"@liveblocks/react": "^1.10.4",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@prisma/client": "^5.11.0",
"@prisma/extension-accelerate": "^1.0.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",