From 7b9358a4f0f95431e9012b6d9a4330fc17e73dc7 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 06 六月 2024 11:13:47 +0800
Subject: [PATCH] ♥️发布 5.2.0-BETA2 公测版本
---
ruoyi-common/ruoyi-common-redis/src/main/java/org/dromara/common/redis/utils/RedisUtils.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 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 ee58411..67be2fb 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
@@ -65,6 +65,12 @@
consumer.accept(msg);
}
+ /**
+ * 鍙戝竷娑堟伅鍒版寚瀹氱殑棰戦亾
+ *
+ * @param channelKey 閫氶亾key
+ * @param msg 鍙戦�佹暟鎹�
+ */
public static <T> void publish(String channelKey, T msg) {
RTopic topic = CLIENT.getTopic(channelKey);
topic.publish(msg);
@@ -107,7 +113,11 @@
bucket.setAndKeepTTL(value);
} catch (Exception e) {
long timeToLive = bucket.remainTimeToLive();
- setCacheObject(key, value, Duration.ofMillis(timeToLive));
+ if (timeToLive == -1) {
+ setCacheObject(key, value);
+ } else {
+ setCacheObject(key, value, Duration.ofMillis(timeToLive));
+ }
}
} else {
bucket.set(value);
@@ -255,6 +265,18 @@
}
/**
+ * 杩藉姞缂撳瓨List鏁版嵁
+ *
+ * @param key 缂撳瓨鐨勯敭鍊�
+ * @param data 寰呯紦瀛樼殑鏁版嵁
+ * @return 缂撳瓨鐨勫璞�
+ */
+ public static <T> boolean addCacheList(final String key, final T data) {
+ RList<T> rList = CLIENT.getList(key);
+ return rList.add(data);
+ }
+
+ /**
* 娉ㄥ唽List鐩戝惉鍣�
* <p>
* key 鐩戝惉鍣ㄩ渶寮�鍚� `notify-keyspace-events` 绛� redis 鐩稿叧閰嶇疆
@@ -279,6 +301,19 @@
}
/**
+ * 鑾峰緱缂撳瓨鐨刲ist瀵硅薄(鑼冨洿)
+ *
+ * @param key 缂撳瓨鐨勯敭鍊�
+ * @param form 璧峰涓嬫爣
+ * @param to 鎴涓嬫爣
+ * @return 缂撳瓨閿�煎搴旂殑鏁版嵁
+ */
+ public static <T> List<T> getCacheListRange(final String key, int form, int to) {
+ RList<T> rList = CLIENT.getList(key);
+ return rList.range(form, to);
+ }
+
+ /**
* 缂撳瓨Set
*
* @param key 缂撳瓨閿��
@@ -291,6 +326,18 @@
}
/**
+ * 杩藉姞缂撳瓨Set鏁版嵁
+ *
+ * @param key 缂撳瓨鐨勯敭鍊�
+ * @param data 寰呯紦瀛樼殑鏁版嵁
+ * @return 缂撳瓨鐨勫璞�
+ */
+ public static <T> boolean addCacheSet(final String key, final T data) {
+ RSet<T> rSet = CLIENT.getSet(key);
+ return rSet.add(data);
+ }
+
+ /**
* 娉ㄥ唽Set鐩戝惉鍣�
* <p>
* key 鐩戝惉鍣ㄩ渶寮�鍚� `notify-keyspace-events` 绛� redis 鐩稿叧閰嶇疆
--
Gitblit v1.9.3