Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make general semaphore (add an option to limit to # of resources) #5

Open
bradvogel opened this issue Apr 20, 2017 · 0 comments
Open

Comments

@bradvogel
Copy link
Contributor

Right now this module implements a binary semaphore pattern: only one resource is allowed inside the critical code block at a time. It would be nice to have an option that allows us to specify the number of resources that are allowed in, so a true semaphore. This API could be something like:

var testLock = new Lock({
  redis: 'redis://localhost:6381',
  namespace: 'mylock',
  number: 5
});

testLock.acquireLock(id, 60 * 1000 /* Lock expires after 60sec if not released */ , function(err, lock) {
   // Up to 5 resources are allowed inside the code block at time
});
@bradvogel bradvogel changed the title Make true semaphore (add an option to limit to # of resources) Make general semaphore (add an option to limit to # of resources) Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant