From e86765c6bc716f566738d7b2d9e309cbd5b25e87 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期五, 28 七月 2023 13:53:05 +0800 Subject: [PATCH] * update springboot 3.0.8 => 3.1.2 * update spring-mybatis 3.0.1 => 3.0.2 * update easyexcel 3.3.1 => 3.3.2 * update hutool 5.8.18 => 5.8.20 * update redisson 3.20.1 => 3.23.1 * update dynamic-ds 4.1.1 => 4.1.2 * update mapstruct-plus 1.3.1 => 1.3.5 * update aws-java-sdk-s3 1.12.400 => 1.12.517 * update maven-surefire-plugin 3.0.0 => 3.1.2 --- ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 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 fd20ba0..9f59f69 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 @@ -1,8 +1,8 @@ package org.dromara.common.redis.utils; -import org.dromara.common.core.utils.SpringUtils; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.dromara.common.core.utils.SpringUtils; import org.redisson.api.*; import java.time.Duration; @@ -127,6 +127,18 @@ bucket.setAsync(value); bucket.expireAsync(duration); batch.execute(); + } + + /** + * 濡傛灉涓嶅瓨鍦ㄥ垯璁剧疆 骞惰繑鍥� true 濡傛灉瀛樺湪鍒欒繑鍥� false + * + * @param key 缂撳瓨鐨勯敭鍊� + * @param value 缂撳瓨鐨勫�� + * @return set鎴愬姛鎴栧け璐� + */ + public static <T> boolean setObjectIfAbsent(final String key, final T value, final Duration duration) { + RBucket<T> bucket = CLIENT.getBucket(key); + return bucket.setIfAbsent(value, duration); } /** @@ -375,6 +387,21 @@ } /** + * 鍒犻櫎Hash涓殑鏁版嵁 + * + * @param key Redis閿� + * @param hKeys Hash閿� + */ + public static <T> void delMultiCacheMapValue(final String key, final Set<String> hKeys) { + RBatch batch = CLIENT.createBatch(); + RMapAsync<String, T> rMap = batch.getMap(key); + for (String hKey : hKeys) { + rMap.removeAsync(hKey); + } + batch.execute(); + } + + /** * 鑾峰彇澶氫釜Hash涓殑鏁版嵁 * * @param key Redis閿� -- Gitblit v1.9.3