From 49e17e776c2276ee7f87ca4d59fe8386060d7c64 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sat, 1 Jul 2023 04:07:50 -0400 Subject: [PATCH] refactor: examine by get instead of exists --- packages/backend/src/services/note/create.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 6eb0df8170..f00678ce22 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -483,14 +483,14 @@ export default async ( const lock = new Mutex(redisClient, "publishedNote"); await lock.acquire(); try { - const exists = (await redisClient.exists(publishKey)) > 0; - if (!exists) { - await redisClient.set(publishKey, 1, "EX", 30); + const published = (await redisClient.get(publishKey)) !== null; + if (!published) { + await redisClient.set(publishKey, "done", "EX", 30); if (noteToPublish.renoteId) { // Prevents other threads from publishing the boosting post await redisClient.set( `publishedNote:${noteToPublish.renoteId}`, - 1, + "done", "EX", 30, );