工作原理
sequenceDiagram
participant Layout
participant Sidebar
participant Page
participant Profile
participant Memo as 请求记忆
participant API as 数据库/API
Layout->>Memo: getCurrentUser()
Memo->>API: 第1次:真正请求
API-->>Memo: 返回用户数据
Memo-->>Layout: 返回数据
Sidebar->>Memo: getCurrentUser()
Note over Memo: 已有缓存,直接返回
Memo-->>Sidebar: 返回数据(复用)
Page->>Memo: getCurrentUser()
Note over Memo: 已有缓存,直接返回
Memo-->>Page: 返回数据(复用)
Profile->>Memo: getCurrentUser()
Note over Memo: 已有缓存,直接返回
Memo-->>Profile: 返回数据(复用)
Note over Memo: 请求结束,缓存销毁