From a286aba4327a1207d27acbaabe0eb833bc46a5a9 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 6 Dec 2024 17:39:12 +0000 Subject: [PATCH] Refactor Semaphore class to streamline lockOptions initialization --- Common/Server/Infrastructure/Semaphore.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Common/Server/Infrastructure/Semaphore.ts b/Common/Server/Infrastructure/Semaphore.ts index 631f9e062a6..a1874d38d11 100644 --- a/Common/Server/Infrastructure/Semaphore.ts +++ b/Common/Server/Infrastructure/Semaphore.ts @@ -23,23 +23,20 @@ export default class Semaphore { throw new Error("Redis client is not connected"); } + const lockOptions: LockOptions = {}; - const lockOptions: LockOptions = { - - }; - - if(data.lockTimeout) { + if (data.lockTimeout) { lockOptions.lockTimeout = data.lockTimeout; } - if(data.acquireTimeout) { + if (data.acquireTimeout) { lockOptions.acquireTimeout = data.acquireTimeout; } const mutex: SemaphoreMutex = new Mutex( client, data.namespace + "-" + key, - lockOptions + lockOptions, ); await mutex.acquire();