From 3924a65e02249edb90daf22788a9bbb87882d20a Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 23 Jul 2023 23:28:41 -0400 Subject: [PATCH] Don't use locks when redis disabled --- src/utils/redisLock.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/redisLock.ts b/src/utils/redisLock.ts index 46f7998..ac9a32b 100644 --- a/src/utils/redisLock.ts +++ b/src/utils/redisLock.ts @@ -1,3 +1,4 @@ +import { config } from "../config"; import redis from "../utils/redis"; import { Logger } from "./logger"; @@ -11,6 +12,13 @@ export type AcquiredLock = { }; export async function acquireLock(key: string, timeout = defaultTimeout): Promise { + if (!config.redis?.enabled) { + return { + status: true, + unlock: () => void 0 + }; + } + try { const result = await redis.set(key, "1", { PX: timeout,