refactor: examine by get instead of exists

This commit is contained in:
Namekuji 2023-07-01 04:07:50 -04:00
parent ab789f2ca8
commit 49e17e776c
No known key found for this signature in database
GPG Key ID: 1D62332C07FBA532
1 changed files with 4 additions and 4 deletions

View File

@ -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,
);