先看内存中的数据是否为空,不为空直接返回,为空查询redis,看redis中的数据是否为空,不为空直接返回,为空利用分布式锁查询mysql,查不到重新执行该流程,查到到内存和redis,然后返回数据。 帮我给以上逻辑生成个流程图
时间: 2023-06-13 12:05:39 浏览: 132
好的,以下是你所描述的逻辑的流程图:
```
+---------------------+ +----------------+
| Check if data exists| | Return data |
+---------------------+ +----------------+
| |
| Data exists in memory |
V V
+---------------------+ +----------------+
| Return data | | Return data |
+---------------------+ +----------------+
| |
| Data not in memory, check redis |
V V
+---------------------+ +----------------+
| Data exists in redis| | Query MySQL |
+---------------------+ +----------------+
| |
| Data not in redis, lock and query |
V V
+---------------------+ +----------------+
| Query MySQL success | | Query failed, |
| |----------------| retry the whole|
| Store in memory | | process |
| Store in redis | +----------------+
+---------------------+
```
阅读全文