Wiki源代码Redis源码

由用户 xu yang 在 2022/04/27 12:25 保存的版本 6.1

Show last authors
1 get命令本质是调用了lookupKeyRead这个底层方法,
2 lookupKeyRead方法如下:
3
4 {{plantuml}}
5 @startuml
6 start
7
8
9 : lookupKeyReadWithFlags;
10
11
12 end
13 @enduml
14 {{/plantuml}}
15
16
17 lookupKeyReadWithFlags方法如下:
18
19 {{plantuml}}
20 @startuml
21 start
22
23 if (调用expireIfNeeded方法判断key是否过期) then(1)
24 if (当前环境为主节点) then(yes)
25 :返回null;
26 stop
27 endif
28
29 if (当前环境为从节点,并且命令为读的时候,那说明key过期是安全的) then(yes)
30 :返回null;
31 stop
32 endif
33 endif
34
35 :调用lookupKey方法,查询value的值;
36
37
38 :返回查询的结果;
39
40 end
41 @enduml
42 {{/plantuml}}