mirror of
https://github.com/doocs/advanced-java.git
synced 2025-03-24 10:50:06 +08:00
fix: update distributed-lock-redis-vs-zookeeper and close #210
This commit is contained in:
parent
25fdbe054b
commit
72e61d4bfb
@ -52,7 +52,7 @@ end
|
||||
这个场景是假设有一个 Redis cluster,有 5 个 Redis master 实例。然后执行如下步骤获取一把锁:
|
||||
|
||||
1. 获取当前时间戳,单位是毫秒;
|
||||
2. 跟上面类似,轮流尝试在每个 master 节点上创建锁,过期时间较短,一般就几十毫秒;
|
||||
2. 跟上面类似,轮流尝试在每个 master 节点上创建锁,超时时间较短,一般就几十毫秒(客户端为了获取锁而使用的超时时间比自动释放锁的总时间要小。例如,如果自动释放时间是 10 秒,那么超时时间可能在 `5~50` 毫秒范围内);
|
||||
3. 尝试在**大多数节点**上建立一个锁,比如 5 个节点就要求是 3 个节点 `n / 2 + 1` ;
|
||||
4. 客户端计算建立好锁的时间,如果建立锁的时间小于超时时间,就算建立成功了;
|
||||
5. 要是锁建立失败了,那么就依次之前建立过的锁删除;
|
||||
|
Loading…
Reference in New Issue
Block a user