更新 Redis扩展部分.md
This commit is contained in:
parent
f28a2cf49b
commit
43f89b2ad6
10
Redis扩展部分.md
10
Redis扩展部分.md
|
@ -12,7 +12,7 @@
|
|||
|
||||
分布式锁的核心思想就是让大家都使用同一把锁,只要大家使用的是同一把锁,那么我们就能锁住线程,不让线程进行,让程序串行执行,这就是分布式锁的核心思路
|
||||
|
||||
![image-20231007214715309](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/1.png?Expires=1723640177&OSSAccessKeyId=TMP.3KfeJz2GfydC5m533sXWc3x8M2AoBTEmroU3YwdYX4zeccmetAxNCv2ZYhrhNTFVWP6fUHFL3tEbZ2xPoj72x22vyq3ANJ&Signature=RGr6kkgB91djekjb4fo%2F87cZC%2Bo%3D)
|
||||
![image-20231007214715309](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/1.png)
|
||||
|
||||
#### 2.分布式锁满足的条件
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
安全性:安全也是程序中必不可少的一环
|
||||
|
||||
![image-20231007215001368](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/2.png?Expires=1723640261&OSSAccessKeyId=TMP.3KfeJz2GfydC5m533sXWc3x8M2AoBTEmroU3YwdYX4zeccmetAxNCv2ZYhrhNTFVWP6fUHFL3tEbZ2xPoj72x22vyq3ANJ&Signature=2rF7nCnjr4rZfgUiK6CgIekpLng%3D)
|
||||
![image-20231007215001368](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/2.png)
|
||||
|
||||
#### 3.常见的分布式锁
|
||||
|
||||
|
@ -36,7 +36,7 @@ Redis:作为分布式锁是非常常见的一种使用方式,现在企业级
|
|||
|
||||
Zookeeper:也是企业级开发中较好的一个实现分布式锁的方案
|
||||
|
||||
![image-20231007215146879](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/3.png?Expires=1723640278&OSSAccessKeyId=TMP.3KfeJz2GfydC5m533sXWc3x8M2AoBTEmroU3YwdYX4zeccmetAxNCv2ZYhrhNTFVWP6fUHFL3tEbZ2xPoj72x22vyq3ANJ&Signature=28Xrz%2B08cCuUZhrAzG0dogX5J0c%3D)
|
||||
![image-20231007215146879](https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/3.png)
|
||||
|
||||
#### 3.设置分布式锁
|
||||
|
||||
|
@ -67,11 +67,11 @@ Zookeeper:也是企业级开发中较好的一个实现分布式锁的方案
|
|||
|
||||
我们利用redis 的setNx方法,当有多个线程进入时,我们就利用该方法,第一个线程进入时,redis 中就有这个key 了,返回了1,如果结果是1,则表示他抢到了锁,那么他去执行业务,然后再删除锁,退出锁逻辑,没有抢到锁的,等待一定时间后重试即可
|
||||
|
||||
<img src="https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/4.png?Expires=1723640311&OSSAccessKeyId=TMP.3KfeJz2GfydC5m533sXWc3x8M2AoBTEmroU3YwdYX4zeccmetAxNCv2ZYhrhNTFVWP6fUHFL3tEbZ2xPoj72x22vyq3ANJ&Signature=3WWhbZv%2BNWLggrOWyyqsN78zZsw%3D" alt="image-20231007220404622" style="zoom:50%;" />
|
||||
<img src="https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/4.png" alt="image-20231007220404622" style="zoom:50%;" />
|
||||
|
||||
#### 6.锁的基本接口
|
||||
|
||||
<img src="https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/5.png?Expires=1723640334&OSSAccessKeyId=TMP.3KfeJz2GfydC5m533sXWc3x8M2AoBTEmroU3YwdYX4zeccmetAxNCv2ZYhrhNTFVWP6fUHFL3tEbZ2xPoj72x22vyq3ANJ&Signature=P8l0%2FqG6OMtX%2BWtEn3Qu287RUQQ%3D" alt="image-20231007220504083" style="zoom:50%;" />
|
||||
<img src="https://oss-wxin-resource.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/Redis/5.png" alt="image-20231007220504083" style="zoom:50%;" />
|
||||
|
||||
## 二:Redis故障的排查思路
|
||||
|
||||
|
|
Loading…
Reference in New Issue