Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
2.1 | 1 | get命令本质是调用了lookupKeyRead这个底层方法, |
2 | lookupKeyRead方法如下: | ||
3 | |||
![]() |
1.1 | 4 | {{plantuml}} |
5 | @startuml | ||
6 | start | ||
7 | |||
8 | |||
![]() |
2.1 | 9 | : lookupKeyReadWithFlags; |
![]() |
1.1 | 10 | |
11 | |||
12 | end | ||
13 | @enduml | ||
14 | {{/plantuml}} | ||
15 | |||
![]() |
2.1 | 16 | |
17 | lookupKeyReadWithFlags方法如下: | ||
18 | |||
![]() |
1.1 | 19 | {{plantuml}} |
20 | @startuml | ||
21 | start | ||
22 | |||
![]() |
8.1 | 23 | if(调用expireIfNeeded方法判断key是否过期)then(1) |
![]() |
12.1 | 24 | note left |
25 | 返回1代表已经过期 | ||
26 | endnote | ||
![]() |
8.1 | 27 | if(当前环境为主节点)then(yes) |
![]() |
9.1 | 28 | :返回null; |
![]() |
2.1 | 29 | stop |
30 | endif | ||
![]() |
1.1 | 31 | |
![]() |
8.1 | 32 | if(当前环境为从节点,并且命令为读的时候,那说明key过期是安全的)then(yes) |
![]() |
2.1 | 33 | :返回null; |
34 | stop | ||
35 | endif | ||
![]() |
10.1 | 36 | endif |
![]() |
1.1 | 37 | |
![]() |
11.1 | 38 | :调用lookupKey方法,查询value的值; |
![]() |
10.1 | 39 | if(返回值为空)then(yes) |
![]() |
7.1 | 40 | :缓存命中+1; |
41 | else(no) | ||
42 | :缓存非命中+1; | ||
43 | endif | ||
![]() |
5.1 | 44 | |
![]() |
2.1 | 45 | :返回查询的结果; |
46 | |||
![]() |
1.1 | 47 | end |
48 | @enduml | ||
49 | {{/plantuml}} |