iPass cache gateway 源码

容量管理: zones.rs 直读 nginx file_cache 共享内存记账(双轴: 磁盘 + keys_zone 索引内存), ?scan=1 扫盘上限 20 万文件; POST /api/admin/cache/purge 整区清理(只删文件不删目录, 根治 [crit] mkdir failed); POST /api/admin/cache/invalidate 按制品精准失效(预览->确认两步式, glob/子串, 删除上限 5000/扫描上限 20 万); GET /api/admin/cache 新增 capacity 块; 前端容量面板 + 按制品失效工具条; 测试 test-cache-capacity.sh 48/48(容量 27 + 精准失效 21, 含 EXPECT_MIN 护栏与前端静态契约); docs 容量管理章节
This commit is contained in:
ssw committed 2026-09-21 09:25:11 +08:00
commit 43718bd0c4
324 files changed
+40403

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
nginx: the configuration file /Users/rong/Desktop/cache/tests/cache/.run/nginx.conf syntax is ok
nginx: configuration file /Users/rong/Desktop/cache/tests/cache/.run/nginx.conf test is successful
2026/09/20 21:01:36 [error] 63867#0: *1 "/Users/rong/Desktop/cache/tests/cache/.run/html/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: _, request: "HEAD / HTTP/1.1", host: "127.0.0.1:18083"
2026/09/20 21:01:52 [notice] 64199#0: signal process started
+1
View File
@@ -0,0 +1 @@
mock upstream on 18999
+105
View File
@@ -0,0 +1,105 @@
# ============================================================================
# 统一制品缓存 · 本机自测配置(不加载 ipass 模块,纯 nginx proxy_cache)
#
# 验证对象:六类生态的「代理缓存」这一层本身(MISS→HIT / Range / PURGE /
# X-Cache-Status)。生产环境由 server.cache.conf 在每 location 加 `ipass_cache on`
# 接入 ipass 的身份/配额/命中计量,缓存引擎完全一致。
#
# 上游统一指向本机 mock_upstream.py(18999);按生态分 zone 与缓存键前缀,
# 各生态互不串档。PURGE 用 map 限制仅 127.0.0.1(无需 rewrite 模块)。
# ============================================================================
worker_processes 1;
error_log /Users/rong/Desktop/cache/tests/cache/.run/logs/error.log warn;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
access_log off;
# 六类生态各自的缓存区(热层=本地盘;S3 冷层预留见生产 conf)
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/go levels=1:2 keys_zone=go:10m max_size=1g inactive=7d;
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/cargo levels=1:2 keys_zone=cargo:10m max_size=1g inactive=7d;
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/pypi levels=1:2 keys_zone=pypi:10m max_size=1g inactive=7d;
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/npm levels=1:2 keys_zone=npm:10m max_size=1g inactive=7d;
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/maven levels=1:2 keys_zone=maven:10m max_size=1g inactive=7d;
proxy_cache_path /Users/rong/Desktop/cache/tests/cache/.run/cache/docker levels=1:2 keys_zone=docker:10m max_size=5g inactive=7d;
# 假上游(确定性,支持 Range)
upstream mock { server 127.0.0.1:18999; }
server {
listen 127.0.0.1:18083;
server_name _;
# ---------- go (Go modules proxy) ----------
location /go/ {
proxy_pass http://mock/;
proxy_cache go;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
# ---------- cargo (Rust crates) ----------
location /cargo/ {
proxy_pass http://mock/;
proxy_cache cargo;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
# ---------- pypi (Python) ----------
location /pypi/ {
proxy_pass http://mock/;
proxy_cache pypi;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
# ---------- npm (Node) ----------
location /npm/ {
proxy_pass http://mock/;
proxy_cache npm;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
# ---------- maven (Java) ----------
location /maven/ {
proxy_pass http://mock/;
proxy_cache maven;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
# ---------- docker (OCI registry;生产含 token 透传,自测仅 GET 缓存) ----------
location /docker/ {
proxy_pass http://mock/;
proxy_cache docker;
proxy_cache_key $scheme$proxy_host$request_uri;
proxy_cache_valid 200 302 1h;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_force_ranges on;
add_header X-Cache-Status $upstream_cache_status;
}
}
}
+8
View File
@@ -0,0 +1,8 @@
GET /pkg-a auth=-
GET /pkg-a auth=-
GET /pkg-a auth=-
GET /pkg-a auth=-
GET /pkg-a auth=-
GET /pkg-a auth=-
GET /biglayer auth=-
GET /pkg-a auth=-