bsm / redislock

Simplified distributed locking implementation using Redis
Other
1.45k stars 157 forks source link

Add support for secret key based lock reobtaining #51

Closed janosmiko closed 2 years ago

janosmiko commented 2 years ago

Using this PR, you are able to obtain a lock that was already locked (e.g.: it was created by other process).

To make it possible, you have to provide the same Secret during calling the Obtain() function.

dim commented 2 years ago

Sorry Janos. Thank you for the contribution but this is not going to work. The random token prevents two clients from accidentally accessing the same resource more than once. Having a shared secret would most certainly result in race conditions that you are trying to avoid.