a way to achieve distributed lock by redis module
How to install
git clone https://github.com/wujunwei/redlock cd redlock make //and load the module in redis cli or add it into the conf module load redlock.so
How to use
- slock.lock lock_key expire the comand lock will return result immediately ,you shall call lock in a while or give up locking
- SLOCK.INFO key this command will return an array with two var, first is the client id and second is the time when client require the lock.
- Slock.unlock key release the lock, if the lock wasn't been created by the same client, it will fail with 0.
PLEASE NOTE: The module does NOT support spin lock,use it carefully.