Don't use locks when redis disabled

This commit is contained in:
Ajay 2023-07-23 23:28:41 -04:00
parent a4de94bede
commit 3924a65e02

View file

@ -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<AcquiredLock> {
if (!config.redis?.enabled) {
return {
status: true,
unlock: () => void 0
};
}
try {
const result = await redis.set(key, "1", {
PX: timeout,