diff --git a/README.md b/README.md index 045ba15..6cf9ef4 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A scrum poker tool that helps agile teams plan their sprints in real-time. - Real-time pub/sub: Ably - ORM: Drizzle ORM - Database: Turso (libSQL) -- Cache: Redis +- Cache: Upstash (Redis) ## Versioning diff --git a/app/_utils/types.ts b/app/_utils/types.ts index fbbdcac..c9eb7c3 100644 --- a/app/_utils/types.ts +++ b/app/_utils/types.ts @@ -4,7 +4,6 @@ export const EventTypes = { ROOM_LIST_UPDATE: "room.list.update", ROOM_UPDATE: "room.update", VOTE_UPDATE: "vote.update", - STATS_UPDATE: "stats.update", } as const; export type EventType = BetterEnum; diff --git a/app/api/internal/room/[roomId]/route.ts b/app/api/internal/room/[roomId]/route.ts index 9a12d7d..2028b14 100644 --- a/app/api/internal/room/[roomId]/route.ts +++ b/app/api/internal/room/[roomId]/route.ts @@ -150,8 +150,6 @@ export async function PUT( } await db.delete(votes).where(eq(votes.roomId, params.roomId)); - - await invalidateCache(`kv_votes_${params.roomId}`); } const newRoom = await db diff --git a/app/api/internal/room/[roomId]/vote/route.ts b/app/api/internal/room/[roomId]/vote/route.ts index 327ffdd..a6ccbd4 100644 --- a/app/api/internal/room/[roomId]/vote/route.ts +++ b/app/api/internal/room/[roomId]/vote/route.ts @@ -1,6 +1,5 @@ import { type NextRequest, NextResponse } from "next/server"; -import { invalidateCache } from "@/_lib/redis"; import { db } from "@/_lib/db"; import { votes } from "@/_lib/schema"; import { createId } from "@paralleldrive/cuid2"; @@ -47,20 +46,12 @@ export async function PUT( const success = upsertResult.rowsAffected > 0; if (success) { - await invalidateCache(`kv_votes_${params.roomId}`); - await publishToChannel( `${params.roomId}`, EventTypes.VOTE_UPDATE, reqBody.value ); - await publishToChannel( - `stats`, - EventTypes.STATS_UPDATE, - JSON.stringify(success) - ); - return NextResponse.json(upsertResult, { status: 200, statusText: "SUCCESS", diff --git a/app/api/internal/room/[roomId]/votes/route.ts b/app/api/internal/room/[roomId]/votes/route.ts index 0f2d00b..2334f27 100644 --- a/app/api/internal/room/[roomId]/votes/route.ts +++ b/app/api/internal/room/[roomId]/votes/route.ts @@ -1,6 +1,5 @@ import { NextResponse } from "next/server"; -import { fetchCache, setCache } from "@/_lib/redis"; import { db } from "@/_lib/db"; import { votes } from "@/_lib/schema"; import { eq } from "drizzle-orm"; @@ -18,31 +17,12 @@ export async function GET( }); } - const cachedResult = await fetchCache< - { - id: string; - value: string; - created_at: Date; - userId: string; - roomId: string; - }[] - >(`kv_votes_${params.roomId}`); + const votesByRoomId = await db.query.votes.findMany({ + where: eq(votes.roomId, params.roomId), + }); - if (cachedResult) { - return NextResponse.json(cachedResult, { - status: 200, - statusText: "SUCCESS!", - }); - } else { - const votesByRoomId = await db.query.votes.findMany({ - where: eq(votes.roomId, params.roomId), - }); - - await setCache(`kv_votes_${params.roomId}`, votesByRoomId); - - return NextResponse.json(votesByRoomId, { - status: 200, - statusText: "SUCCESS!", - }); - } + return NextResponse.json(votesByRoomId, { + status: 200, + statusText: "SUCCESS!", + }); } diff --git a/package.json b/package.json index cd1d599..f4f6b4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sprintpadawan", - "version": "3.1.0", + "version": "3.1.1", "description": "Plan. Sprint. Repeat.", "private": true, "scripts": {