Skip to content

Commit

Permalink
Refactor Semaphore class to streamline lockOptions initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Dec 6, 2024
1 parent a3f1302 commit a286aba
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Common/Server/Infrastructure/Semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a286aba

Please sign in to comment.