mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Don't use locks when redis disabled
This commit is contained in:
parent
a4de94bede
commit
3924a65e02
1 changed files with 8 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue