refactor: examine by get instead of exists
This commit is contained in:
parent
ab789f2ca8
commit
49e17e776c
|
@ -483,14 +483,14 @@ export default async (
|
||||||
const lock = new Mutex(redisClient, "publishedNote");
|
const lock = new Mutex(redisClient, "publishedNote");
|
||||||
await lock.acquire();
|
await lock.acquire();
|
||||||
try {
|
try {
|
||||||
const exists = (await redisClient.exists(publishKey)) > 0;
|
const published = (await redisClient.get(publishKey)) !== null;
|
||||||
if (!exists) {
|
if (!published) {
|
||||||
await redisClient.set(publishKey, 1, "EX", 30);
|
await redisClient.set(publishKey, "done", "EX", 30);
|
||||||
if (noteToPublish.renoteId) {
|
if (noteToPublish.renoteId) {
|
||||||
// Prevents other threads from publishing the boosting post
|
// Prevents other threads from publishing the boosting post
|
||||||
await redisClient.set(
|
await redisClient.set(
|
||||||
`publishedNote:${noteToPublish.renoteId}`,
|
`publishedNote:${noteToPublish.renoteId}`,
|
||||||
1,
|
"done",
|
||||||
"EX",
|
"EX",
|
||||||
30,
|
30,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue