Просмотр исходного кода

2023-10-25 redis锁修改成存储值校验重复插入日子。

chaiyunlong лет назад: 2
Родитель
Сommit
1e62c5c43b

+ 3 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndWorkListener.java

@@ -145,9 +145,9 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
             map.put("riskPlanTriggerTime",dateFormat.format(date));
 
             String key = BaseConstants.REDIS_LOCK + ""+beaconStr[2];
-            if (!redisService.isExistLock(key)) {
+            if (!redisService.hasKey(key)) {
                 try{
-                    redisService.lock(key,5);
+                    redisService.setCacheObject(key,key,5L, TimeUnit.MINUTES);
 
                     if(beaconStr[2]!=null){
                         LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
@@ -204,7 +204,7 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
                         remoteAirBottleService.beaconAdd(tagMap);
                     }
                 }finally {
-                    redisService.unLock(key);
+                    redisService.deleteObject(key);
                 }
             }
         }