danielstjules / redislock

Node distributed locking using redis
MIT License
110 stars 32 forks source link

Add support for lockCheck #9

Closed rustyconover closed 7 years ago

rustyconover commented 7 years ago

Check to see if a lock is held, but don't acquire it. Retries until the lock is no longer held.

danielstjules commented 7 years ago

Thanks for the PR! Taking a look now

danielstjules commented 7 years ago

I'm wondering if a slightly different interface would be more flexible:

danielstjules commented 7 years ago

Nevermind, a release event wouldn't cover expiration in redis, and trying to resolve that with the current lock design would probably require key-space notifications being enabled. There's also probably no need for these events at all.

danielstjules commented 7 years ago

I can see lockCheck being abused to check state and conditionally acquire locks, which I think is an antipattern since such operations wouldn't be atomic. Could you give an example of your use case?

danielstjules commented 7 years ago

Gonna close for now due to inactivity, but thanks! :)