From 5738f16f665490894c329317bfda125c121af62d Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 8 May 2023 15:38:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20lock=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/RedisTemplateService.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/service/RedisTemplateService.java b/backend/src/main/java/io/metersphere/api/service/RedisTemplateService.java index 1ed5367d12..5941f4a1f5 100644 --- a/backend/src/main/java/io/metersphere/api/service/RedisTemplateService.java +++ b/backend/src/main/java/io/metersphere/api/service/RedisTemplateService.java @@ -90,7 +90,19 @@ public class RedisTemplateService { * 加锁 */ public boolean lock(String key, String value) { - return redisTemplate.opsForValue().setIfAbsent(StringUtils.join(PRX, key), value, TIME_OUT, TimeUnit.SECONDS); + boolean hasReport = redisTemplate.opsForValue().setIfAbsent( + StringUtils.join(PRX, key), + value, + TIME_OUT, + TimeUnit.MINUTES); + if(!hasReport){ + redisTemplate.opsForValue().setIfPresent( + StringUtils.join(PRX, key), + value, + TIME_OUT, + TimeUnit.MINUTES); + } + return hasReport; } public boolean hasReport(String key, String reportId) {