Skip to content

Commit

Permalink
定时作业服务修复分布式锁Key,防止多系统共用一个Redis库时导致key重复
Browse files Browse the repository at this point in the history
  • Loading branch information
猿人易 committed May 6, 2024
1 parent d8bcb52 commit 8f46b2c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NewLife.CubeNC/Services/JobService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Reflection;
using NewLife.Caching;
using NewLife.Common;
using NewLife.Cube.Entity;
using NewLife.Cube.Jobs;
using NewLife.Log;
Expand Down Expand Up @@ -268,7 +269,7 @@ public void Stop()
private Boolean CheckRunning(CronJob job)
{
// 检查分布式锁,避免多节点重复执行
var key = $"Job:{job.Id}";
var key = $"{SysConfig.Current.Name}:Job:{job.Id}";
if (CacheProvider != null && !CacheProvider.Cache.Add(key, job.Name, 5)) return false;

// 有时候可能并没有配置Redis,借助数据库事务实现去重,需要20230804版本的XCode
Expand Down

0 comments on commit 8f46b2c

Please sign in to comment.