mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-04 12:43:24 +00:00
Added Redis for Caching and Started Database Query Caching Migration to Redis
This commit is contained in:
parent
f99360d9b9
commit
0f899cb34f
12 changed files with 260 additions and 632 deletions
|
@ -2,6 +2,7 @@ import { auth } from '@clerk/nextjs/server';
|
|||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { db } from '@/lib/db';
|
||||
import { unstable_cache } from 'next/cache';
|
||||
|
||||
export async function GET(
|
||||
req: Request,
|
||||
|
@ -16,27 +17,34 @@ export async function GET(
|
|||
status: 401,
|
||||
});
|
||||
|
||||
const card = await db.card.findUnique({
|
||||
where: {
|
||||
id: params.cardId,
|
||||
list: {
|
||||
board: {
|
||||
orgId,
|
||||
const getCard = unstable_cache(
|
||||
async () => {
|
||||
return await db.card.findUnique({
|
||||
where: {
|
||||
id: params.cardId,
|
||||
list: {
|
||||
board: {
|
||||
orgId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
list: {
|
||||
select: {
|
||||
title: true,
|
||||
include: {
|
||||
list: {
|
||||
select: {
|
||||
title: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
cacheStrategy: {
|
||||
ttl: 30,
|
||||
swr: 60,
|
||||
},
|
||||
});
|
||||
[`card-${params.cardId}`],
|
||||
{
|
||||
tags: [`card-${params.cardId}`],
|
||||
revalidate: false,
|
||||
}
|
||||
);
|
||||
|
||||
const card = await getCard();
|
||||
|
||||
return new NextResponse(JSON.stringify(card), {
|
||||
status: 200,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue