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
});
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: