后端架构更新
This commit is contained in:
+7
-1
@@ -36,7 +36,13 @@ public class DistributedJobLockService {
|
||||
Duration actualTtl = (ttl == null || ttl.isNegative() || ttl.isZero()) ? Duration.ofMinutes(10) : ttl;
|
||||
String key = buildLockKey(jobName);
|
||||
String token = ownerPrefix + ":" + UUID.randomUUID();
|
||||
Boolean locked = stringRedisTemplate.opsForValue().setIfAbsent(key, token, actualTtl);
|
||||
Boolean locked;
|
||||
try {
|
||||
locked = stringRedisTemplate.opsForValue().setIfAbsent(key, token, actualTtl);
|
||||
} catch (Exception ex) {
|
||||
log.warn("[job-lock] acquire skipped jobName={} key={} msg={}", jobName, key, ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
if (!Boolean.TRUE.equals(locked)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user