Skip to content

How to check if the lock has expired? #313

Description

@mbartn
const redlock = new Redlock([ioClient], {
    retryCount: -1,
});


const LOCK_TTL = 1_000; 

const lock = await redlock.acquire(["someKey"], LOCK_TTL)

await new Promise(f => setTimeout(f, 5_000));

await lock.release();

// It never reaches here if the lock has expired

doSomethingElse()

If the lock expires, the code is stuck on release() function.

  • Is this behavior expected? I suspect it retries release() forever based onretryCount, but can I have different retryCount for acquiring and releasing?
  • How do I check if the lock has expired, so I can skip the release() call?

I am connecting to a single Redis node

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions