From f9d9eb2d70458839d292a5d34d18ddc79888f80e Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 12 一月 2023 15:11:56 +0800
Subject: [PATCH] fix 修复 新版本 Redisson 存在与 boot 2.X 的兼容性问题

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/RedisUtils.java |   29 ++++++++++++++---------------
 1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/RedisUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/RedisUtils.java
index 69d3f74..1623808 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/RedisUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/RedisUtils.java
@@ -3,9 +3,7 @@
 import com.ruoyi.common.utils.spring.SpringUtils;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import org.apache.poi.ss.formula.functions.T;
 import org.redisson.api.*;
-import org.redisson.config.Config;
 
 import java.time.Duration;
 import java.util.Collection;
@@ -27,14 +25,6 @@
 public class RedisUtils {
 
     private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
-
-    public static NameMapper getNameMapper() {
-        Config config = CLIENT.getConfig();
-        if (config.isClusterConfig()) {
-            return config.useClusterServers().getNameMapper();
-        }
-        return config.useSingleServer().getNameMapper();
-    }
 
     /**
      * 闄愭祦
@@ -220,6 +210,15 @@
     }
 
     /**
+     * 妫�鏌ョ紦瀛樺璞℃槸鍚﹀瓨鍦�
+     *
+     * @param key 缂撳瓨鐨勯敭鍊�
+     */
+    public static boolean isExistsObject(final String key) {
+        return CLIENT.getBucket(key).isExists();
+    }
+
+    /**
      * 缂撳瓨List鏁版嵁
      *
      * @param key      缂撳瓨鐨勯敭鍊�
@@ -334,7 +333,7 @@
      * @param key 缂撳瓨鐨勯敭鍊�
      * @return key鍒楄〃
      */
-    public static Set<String> getCacheMapKeySet(final String key) {
+    public static <T> Set<String> getCacheMapKeySet(final String key) {
         RMap<String, T> rMap = CLIENT.getMap(key);
         return rMap.keySet();
     }
@@ -438,8 +437,8 @@
      * @return 瀵硅薄鍒楄〃
      */
     public static Collection<String> keys(final String pattern) {
-        Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(getNameMapper().map(pattern));
-        return stream.map(key -> getNameMapper().unmap(key)).collect(Collectors.toList());
+        Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
+        return stream.collect(Collectors.toList());
     }
 
     /**
@@ -448,7 +447,7 @@
      * @param pattern 瀛楃涓插墠缂�
      */
     public static void deleteKeys(final String pattern) {
-        CLIENT.getKeys().deleteByPattern(getNameMapper().map(pattern));
+        CLIENT.getKeys().deleteByPattern(pattern);
     }
 
     /**
@@ -458,6 +457,6 @@
      */
     public static Boolean hasKey(String key) {
         RKeys rKeys = CLIENT.getKeys();
-        return rKeys.countExists(getNameMapper().map(key)) > 0;
+        return rKeys.countExists(key) > 0;
     }
 }

--
Gitblit v1.9.3