docs(vloop): 第 20 章改为全链路端到端还原,同步修正 10/11/12/21/22 及跨章引用

第 20 章由三条链路扩展为六条主干 + 其余链路一览。第 10/11/12 章按当前代码重写热度来源、三条写路径与重试停泊。第 21/22 章同步故障处置与速查表。02/03/04/05/08/16/17/18/19 章清理 popularityMQ 旧设计。验证:node tools/build-nav.js 与 node tools/check-pages.js 均通过。
This commit is contained in:
2026-11-02 22:38:31 +08:00
parent 2354b3d704
commit 3718640c90
26 changed files with 1374 additions and 1607 deletions

View File

@@ -394,15 +394,14 @@ func StartOutboxPoller(db *gorm.DB, tmq *rabbitmq.TimelineMQ) {
<p>视频详情(<code>/video/getDetail</code>)是读多写少的典型场景,所以它有缓存。缓存 TTL 在构造函数里写死:</p>
<pre data-lang="go" data-name="backend/internal/video/video_service.go:18-27">type VideoService struct {
repo *VideoRepository
cache *rediscache.Client
cacheTTL time.Duration
popularityMQ *rabbitmq.PopularityMQ
<pre data-lang="go" data-name="backend/internal/video/video_service.go —— VideoService 与其构造">type VideoService struct {
repo *VideoRepository
cache *rediscache.Client
cacheTTL time.Duration
}
func NewVideoService(repo *VideoRepository, cache *rediscache.Client, popularityMQ *rabbitmq.PopularityMQ) *VideoService {
return &VideoService{repo: repo, cache: cache, cacheTTL: 5 * time.Minute, popularityMQ: popularityMQ}
func NewVideoService(repo *VideoRepository, cache *rediscache.Client) *VideoService {
return &VideoService{repo: repo, cache: cache, cacheTTL: 5 * time.Minute}
}</pre>
<p><code>5 * time.Minute</code> 是硬编码的,不走配置。<code>GetDetail</code> 本身是标准的 cache-aside 加分布式锁防击穿,结构与其他缓存一致:<b>先查缓存 → 未命中抢 <code>lock:</code> 锁(TTL 2 秒)→ 抢到则 double-check 再查库并回填 → 没抢到则 5×20ms 轮询等别人回填 → 都没等到就自己查库兜底。</b></p>
@@ -432,7 +431,7 @@ func NewVideoService(repo *VideoRepository, cache *rediscache.Client, popularity
_ = vs.cache.Del(context.Background(), cacheKey)
}</pre>
<p>它只删了 <code>video:detail:id=&lt;id&gt;</code>。<b>而 Feed 读的是另一个键</b>:<code>video:entity:&lt;id&gt;</code>(<code>feed/service.go:47/69/124/142</code>,TTL 1 小时)。全项目搜索 <code>video:entity</code> 的删除点,只有一处——<code>video/popularity_cache.go:18</code>,由点赞/评论的热度更新链路顺带触发。<b>删除视频的链路从不删它</b>。</p>
<p>它只删了 <code>video:detail:id=&lt;id&gt;</code>。<b>而 Feed 读的是另一个键</b>:<code>video:entity:&lt;id&gt;</code>(<code>feed/service.go:47/69/124/142</code>,TTL 1 小时)。全项目搜索 <code>video:entity</code> 的删除点,只有一处——<code>video/hot_window.go</code> 的 <code>ApplyHotDelta</code>,由点赞/评论的热度更新链路顺带触发。<b>删除视频的链路从不删它</b>。</p>
<div class="tablewrap">
<table>