Skip to content

Commit

Permalink
Merge pull request #8 from Bensigo/development
Browse files Browse the repository at this point in the history
fix: cache issue
  • Loading branch information
Bensigo authored Oct 4, 2023
2 parents 33fb29a + b2a7f9a commit 2a8c9cd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/server/api/routers/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(cacheKey);
const cacheKey = `${ctx.session.user.id}_affirmation_v2`
const cacheData = await kv.get<Activity[]>(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 }})
Expand Down Expand Up @@ -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
})

Expand Down

0 comments on commit 2a8c9cd

Please sign in to comment.