modify: 清除diskcache依赖

This commit is contained in:
2026-09-04 14:50:34 +08:00
parent eaf4089b6f
commit 93be99141f
15 changed files with 522 additions and 88 deletions
+5 -2
View File
@@ -126,11 +126,14 @@ chongming-worker-rs/ # 独立仓库(或 utils/worker-rs/,与 Pyth
| admin Queryable | `worker/<type>/<id>/__admin__`,指令 status/restart/stop/drain/get_config/config_set/rescale | 同一 keyexpr,`admin.rs::handle_admin` 全量分派 | ✅ keyexpr 与指令一致 |
| 优雅排空 | drain:隔离新请求 → 等在途归零(30s 超时强制关闭) | `draining` 标记 + `wait_inflight_zero`(同 30s);先摘 liveliness/业务/admin 再等在途 | ✅ 行为一致 |
| 配置热更 | config_set:仅 index0 落盘(原子写)+ 触发重启,`[workers.config]` 保留键校验 | `persist_worker_config_section`(tmp+rename 原子写)+ `merge_confirmed`/`count_allowed` 保留键校验 | ✅ 语义一致 |
| 配置缓存 | chongming-cache(redis / diskcache)作为 counts/configs 单一事实来源 | `Cache` 抽象:Redis(feature `redis-cache`)+ 无缓存回退 | ✅ Redis 路径一致;本地 diskcache 因格式特性不可复用(多实例走 Redis) |
| 配置缓存 | chongming-cache(redis / sqlite)作为 counts/configs 单一事实来源 | `Cache` 抽象:`sqlite`(feature `local-cache`,本机与 Python 共享同一 .db)+ Redis(feature `redis-cache`)+ 无缓存回退 | ✅ schema 一致,凡 JSON 值均可互通 |
| quota 分摊 | 按在线网关/存活实例均分全局 count(余数给序较早方) | `distribute_quota` / `resolve_worker_count` 同算法 | ✅ 同协议键 `worker:cm:*` |
| CLI | `--config` / `--instance` / `--count` | `examples/demo.rs`:`--config` / `--instance` / `--count` | ✅ 对齐 |
> 注:Python 默认的本地 `diskcache` 后端为 Python 库,Rust 无法读其存储文件格式;故 Rust 侧多实例协同统一走 Redis(`redis-cache` feature),单实例走 `Cache::None`,与 Python「多实例必须 redis/共享卷」约束一致。
> 注:Rust 侧共享缓存已统一为与 Python `chongming-cache` 完全一致的 JSON 协议——本机走
> `sqlite`(`local-cache` feature,跨语言共享同一 `.db`),跨主机走 Redis(`redis-cache`
> feature);缺省无缓存走 `Cache::None`。原 Python 本地 diskcache 后端已被 SQLite 后端
> 直接替换,不再存在「Rust 不可读其本地格式」的限制。
### 3.7 数据库对齐(`chongming_database` ↔ Rust `database.rs`)