Distributed Lock
Simple Distributed Lock Implementation
- When we want to acquire the lock, we run
INCR
. - If the response is
1
, we have acquired the lock. - If the response > 1 (i.e. someone else has acquired the lock), we wait and retry again later.
- When we want to release the lock, we run
DEL
to delete the key.