From d7cfd153b259b2cc07dac80a2d93a592125a0676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com> Date: Tue, 9 Apr 2024 14:33:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?opt=EF=BC=9A=E4=BC=98=E5=8C=96null=20?= =?UTF-8?q?=E7=BC=93=E5=AD=985s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackPush/TrackPushCacheService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index bf365f28..eb4c2504 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -35,9 +35,11 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc { // maybe is null var data = await DoGetPushContentConfigsAsync(subSystemId, customId); + var ttl = 3 * 24 * 60 * 60; + if (data == null) ttl = 5; // ttl 3days await RedisHelper.Client.SetAsync(TrackPushContentKey(subSystemId, customId), - data, 3 * 24 * 60 * 60); + data, ttl); return data; } From 9ddba4f5619c4ca2ac3b7647e99713a6ddeecfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com> Date: Tue, 9 Apr 2024 14:38:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E6=89=8B=E5=8A=A8=20=E5=85=A8?= =?UTF-8?q?=E9=87=8F=20=E6=8E=A8=E9=80=81=20=E6=A0=A1=E9=AA=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventHandlers/TrackPushEventHandler.cs | 4 ++++ .../Services/TrackPush/TrackPushCacheService.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application/EventHandlers/TrackPushEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackPushEventHandler.cs index 9ebea1f6..a9a207e9 100644 --- a/src/SJZY.Track.Application/EventHandlers/TrackPushEventHandler.cs +++ b/src/SJZY.Track.Application/EventHandlers/TrackPushEventHandler.cs @@ -70,6 +70,10 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe // 推送新增,需要根据上一次的推送 推断 本次推送 是否可行 config = await _trackPushCacheService.IsValidPushAsync(order.SubSystemId, order.CustomId, order.LatestPushTrackCode, @event.TrackCode); + if (config is not { IsAutoPush: true }) + { + config = null; + } } } else diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index eb4c2504..e5d413f4 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -68,7 +68,7 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc // find swap cache.FirstOrDefault(x => x.TrackCode == cache[idx + 1].SwapTrackCode); - return matched != null && matched.TrackCode == trackCode && matched.IsAutoPush ? matched : default; + return matched != null && matched.TrackCode == trackCode ? matched : default; } private async Task?> DoGetPushContentConfigsAsync(int subSystemId, int customId)