fix(RouterService): AddRouters 缓存更新用 try-catch 保护
防止缓存写入失败时异常逃逸,确保 DB 写入成功后即使缓存更新失败也返回成功。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| | |
| | | // 重新查询全量路由(此时才包含新增的路由),再写入缓存 |
| | | List<Dt_Router> updatedRouters = BaseDal.QueryData(x => x.InOutType == routerType); |
| | | string cacheKey = $"Router:AllRouters:{(routerType == RouterInOutType.In.ObjToInt() ? "In" : "Out")}"; |
| | | _cacheService.AddOrUpdate(cacheKey, updatedRouters); |
| | | |
| | | try |
| | | { |
| | | _cacheService.AddOrUpdate(cacheKey, updatedRouters); |
| | | } |
| | | catch |
| | | { |
| | | // 缓存更新失败时静默忽略,下次查询会从DB自动重建缓存 |
| | | } |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |