From b2a7f9ab5f5c33999cac9d9489d970af5ac3a85e Mon Sep 17 00:00:00 2001 From: bensigo Date: Wed, 4 Oct 2023 17:00:39 +0400 Subject: [PATCH] fix: cache issue --- src/server/api/routers/activities.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server/api/routers/activities.ts b/src/server/api/routers/activities.ts index 1b575c5..14a25f8 100644 --- a/src/server/api/routers/activities.ts +++ b/src/server/api/routers/activities.ts @@ -29,14 +29,13 @@ export const activityRouter = createTRPCRouter({ const prisma = ctx.prisma; // check for cache - const cacheKey = `${ctx.session.user.id}_affirmation` - const cacheData = await kv.get(cacheKey); + const cacheKey = `${ctx.session.user.id}_affirmation_v2` + const cacheData = await kv.get(cacheKey); console.log({ cacheData }) // log for texting if(cacheData) { - const data = (JSON.parse(cacheData) )as Activity[]; - return data + return cacheData } // const quest = await ctx.prisma.quest.findUnique({ where: { id: input.questId }, include: { goal: true }}) @@ -70,8 +69,8 @@ export const activityRouter = createTRPCRouter({ console.log({ activities }) // set cache data - const currentCache = JSON.stringify(activities) - await kv.set(cacheKey, currentCache, { + + await kv.set(cacheKey, activities, { ex: 86400 })