Skip to content

Commit

Permalink
feat(blog): Delete redis key when comment / reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzuan committed Dec 11, 2024
1 parent ef8f3ff commit 5024280
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/controller/blog/commentBlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BadRequestException } from "@constants/exceptions";
import { rateLimit } from "elysia-rate-limit";
import { createElysia } from "@libs/elysia";
import blogModel from "@models/blog.model";
import { redis } from "@libs/redisClient";

export default createElysia()
.use(blogModel)
Expand All @@ -26,6 +27,8 @@ export default createElysia()
throw new BadRequestException("Blog not found.");
}

await redis.del(`blog.${blog.slug}`);

return {
status: 200,
data: await prismaClient.blogComment.create({
Expand Down
3 changes: 3 additions & 0 deletions src/api/controller/blog/reactionBlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { prismaClient } from "@libs/prismaDatabase";
import { BadRequestException } from "@constants/exceptions";
import { createElysia } from "@libs/elysia";
import blogModel from "@models/blog.model";
import { redis } from "@libs/redisClient";

export default createElysia()
.use(blogModel)
Expand All @@ -20,6 +21,8 @@ export default createElysia()
throw new BadRequestException("Blog not found.");
}

await redis.del(`blog.${blog.slug}`);

const existingReaction = await prismaClient.blogReaction.findFirst({
where: {
blogId: blog.id,
Expand Down

0 comments on commit 5024280

Please sign in to comment.