Skip to content

Commit

Permalink
fix(crawl-redis/lockURL): even shorter lock
Browse files Browse the repository at this point in the history
  • Loading branch information
mogery committed Dec 14, 2024
1 parent ea62aa8 commit 7f7a704
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/lib/crawl-redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export async function lockURL(
plan: sc.plan,
});

const rRes: boolean | undefined = await redlock.using(["crawl:" + id + ":visited_unique:lock"], 5000, {}, async () => {
const rRes: boolean | undefined = await redlock.using(["crawl:" + id + ":visited_unique:lock"], 1000, {}, async () => {
if (typeof sc.crawlerOptions?.limit === "number") {
if (
(await redisConnection.scard("crawl:" + id + ":visited_unique")) >=
Expand Down Expand Up @@ -281,7 +281,7 @@ export async function lockURLs(
plan: sc.plan,
});

await redlock.using(["crawl:" + id + ":visited_unique:lock"], 5000, {}, async () => {
await redlock.using(["crawl:" + id + ":visited_unique:lock"], 1000, {}, async () => {
// Add to visited_unique set
logger.debug("Locking " + urls.length + " URLs...");
await redisConnection.sadd("crawl:" + id + ":visited_unique", ...urls);
Expand Down

0 comments on commit 7f7a704

Please sign in to comment.