From a545f7fc4445f78a51bcf557127a2203faa0e1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 1 Aug 2025 16:30:33 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20setCacheObject=20?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/common/redis/utils/RedisUtils.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java b/ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java index 355cd2931..c433bffad 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java @@ -129,9 +129,9 @@ public class RedisUtils { } catch (Exception e) { long timeToLive = bucket.remainTimeToLive(); if (timeToLive == -1) { - setCacheObject(key, value); + bucket.set(value); } else { - setCacheObject(key, value, Duration.ofMillis(timeToLive)); + bucket.set(value, Duration.ofMillis(timeToLive)); } } } else { @@ -147,11 +147,8 @@ public class RedisUtils { * @param duration 时间 */ public static void setCacheObject(final String key, final T value, final Duration duration) { - RBatch batch = CLIENT.createBatch(); - RBucketAsync bucket = batch.getBucket(key); - bucket.setAsync(value); - bucket.expireAsync(duration); - batch.execute(); + RBucket bucket = CLIENT.getBucket(key); + bucket.set(value, duration); } /**