GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Eureka Server 多级缓存机制 · lzy1985/PassJava-Learning@5d528c7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/13.SpringCloudNetflix源码解析/01.Eureka
    • 07.Eureka源码之Server端的多级缓存机制.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/13.SpringCloudNetflix源码解析/01.Eureka/07.Eureka源码之Server端的多级缓存机制.md‎

Copy file name to clipboardExpand all lines: docs/13.SpringCloudNetflix源码解析/01.Eureka/07.Eureka源码之Server端的多级缓存机制.md
+49-5Lines changed: 49 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
# 呀,注册中心居然藏了一个优秀的缓存架构!
1+
# 呀,Eureka 居然藏了一个优秀的缓存架构!
2+
3+
## 一、前言
24

35
上一讲我们讲到了 Eureka Server 有两级缓存来保存注册信息,来回顾下:
46

57
Server 端那边有缓存机制,分为两级缓存,只读缓存 readOnlyCacheMap 和读写缓存 readOnlyCacheMap。
68

7-
- 默认会先从只读缓存里面找。
8-
- 没有的话,再从读写缓存里面找。
9-
- 找到了的话就更新只读缓存,并返回找到的缓存。
10-
- 还找不到的话,就返回空。
9+
看图更清晰,如下图所示:
10+
11+
![](http://cdn.jayh.club/blog/20211102/BuD0hsas1RKB.png)
12+
13+
本篇悟空会带着大家来看下 Eureka 的缓存架构是怎么样,通过学习这篇,我们也可以借鉴 Eureka 的缓存设计思想,将其运用到项目当中。
14+
15+
## 二、引发的几个思考
16+
17+
我们再来看下 Eureka 源码,其实不难看懂,下面会做解释。
1118

1219
![](http://cdn.jayh.club/blog/20211013/2t7Byj8TBd8H.png)
1320

21+
- 默认会先从`只读`缓存里面找。
22+
- 没有的话,再从`读写`缓存里面找。
23+
- 找到了的话就更新只读缓存,并返回找到的缓存。
24+
- 还找不到的话,就返回空。
25+
1426
带来了三个问题:
1527

1628
(1)两级缓存数据怎么来的?
@@ -19,6 +31,38 @@ Server 端那边有缓存机制,分为两级缓存,只读缓存 readOnlyCach
1931

2032
(3)缓存如何过期?
2133

34+
首先我们先来看下其中的一种缓存结构:读写缓存。
35+
36+
## 三、读写缓存
37+
38+
读写缓存,顾名思义,就是既可以进行读,也可以进行写的缓存。
39+
40+
那用在哪里呢?
41+
42+
### 2.1 写操作时机的原理
43+
44+
当有新的服务实例进行注册或者下线、发生故障时,就会把这个缓存给刷新一下,也就是进行写操作。
45+
46+
如下图所示,最上面的时注册中心,下面三个是服务实例。服务实例发生注册、下线、发生故障,注册中心都是可以感知到的,然后就会主动刷新只读缓存。
47+
48+
![](http://cdn.jayh.club/blog/20211102/FCxGlrfKEdA6.png)
49+
50+
### 2.2 写操作源码
51+
52+
从源码层面我们再来看下读写缓存是什么时候进行写操作的。
53+
54+
55+
56+
57+
58+
## 二、只读缓存数据怎么来的?
59+
60+
61+
62+
## 三、缓存数据如何更新的?
63+
64+
## 四、缓存数据如何过期的?
65+
2266

2367

2468
## 过期

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.