wanshenmean
2026-03-27 71403dd5e730c6966b2754f94b8a2df50729bfd3
fix(RouterService): AddRouters 缓存更新用 try-catch 保护

防止缓存写入失败时异常逃逸,确保 DB 写入成功后即使缓存更新失败也返回成功。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
已修改1个文件
10 ■■■■■ 文件已修改
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
@@ -608,7 +608,15 @@
                // 重新查询全量路由(此时才包含新增的路由),再写入缓存
                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();
            }