缩略图缓存加容量闸与删除联动清理
- Store 增 MaxBytes(默认 256MB):写入后节流扫描(10 分钟一次、同时只跑一个), 超限按 mtime 从旧到新删到 3/4 水位(滞回,避免卡在边界反复删),顺带清掉 进程被杀留下的 .tmp - 命中缓存时 Touch 更新 mtime,淘汰因此是 LRU 而非「最早生成的先死」, 热图不会被误删后反复回源拉存储 - 新增 Purge(sha):后台删除上传文件时连带清掉该图所有宽度的产物与 .failed 标记,否则已删图片会永久占着缓存
This commit is contained in:
@@ -127,6 +127,7 @@ func (a *API) serveThumbFile(w http.ResponseWriter, r *http.Request, path string
|
||||
httpx.NotFound(w)
|
||||
return
|
||||
}
|
||||
a.Thumbs.Touch(path) // 记一次「最近用过」,供容量闸按 LRU 淘汰
|
||||
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
|
||||
http.ServeContent(w, r, path, fi.ModTime(), fp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user