From 07f31ebf50be37327bb950c4481e6ba71ccf43fb Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 28 Sep 2024 16:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chaozhanggui/system/cashierservice/util/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java index 3349961..f10aabc 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java @@ -49,14 +49,14 @@ public class Utils { // 创建线程id, 用作判断 String clientId = UUID.randomUUID().toString(); // 设置分布式锁 - boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS)); + boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS)); int count = 0; while (!lock) { if (count++ > 100) { throw new MsgException("系统繁忙, 稍后再试"); } Thread.sleep(20); - lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS)); + lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS)); } return supplier.get(); } catch (RuntimeException e){