From 74bfaf2f3a8c2661e2c8a512f61f40bfd43b48f3 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期一, 17 二月 2025 18:54:19 +0800
Subject: [PATCH] Merge branch 'master' of http://116.62.18.175:6699/r/smartor
---
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
index 13210c8..8665654 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
@@ -8,10 +8,7 @@
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.BoundSetOperations;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
/**
@@ -19,7 +16,7 @@
*
* @author ruoyi
**/
-@SuppressWarnings(value = {"unchecked" , "rawtypes"})
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
@Component
public class RedisCache {
@Autowired
@@ -127,8 +124,20 @@
* @param dataList 寰呯紦瀛樼殑List鏁版嵁
* @return 缂撳瓨鐨勫璞�
*/
- public <T> long setCacheList(final String key, final List<T> dataList) {
+ public <T> long setCacheListRight(final String key, final List<T> dataList) {
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
+ return count == null ? 0 : count;
+ }
+
+ /**
+ * 缂撳瓨List鏁版嵁
+ *
+ * @param key 缂撳瓨鐨勯敭鍊�
+ * @param dataList 寰呯紦瀛樼殑List鏁版嵁(杩欓噷濡傛灉鏂板鐨勮瘽锛屾槸寰�澶撮儴鏂板)
+ * @return 缂撳瓨鐨勫璞�
+ */
+ public <T> long setCacheListLeft(final String key, final List<T> dataList) {
+ Long count = redisTemplate.opsForList().leftPushAll(key, dataList);
return count == null ? 0 : count;
}
@@ -245,6 +254,19 @@
}
/**
+ * 鍒犻櫎缂撳瓨LIST涓殑鏌愪釜鏁版嵁
+ *
+ * @param key Redis閿�
+ * @param valueToRemove 闇�瑕佸垹闄ょ殑鍊�
+ * @return Long 澶т簬0琛ㄧず鍒犻櫎浜嗗嚑涓紝绛変簬0琛ㄧず娌℃湁鍒犻櫎锛屽皬浜�0琛ㄧず鍦ㄦ墽琛屽垹闄ゆ搷浣滄椂鍙戠敓浜嗛敊璇�
+ */
+ public Long removeElementFromList(String key, String valueToRemove) {
+ ListOperations<String, String> listOps = redisTemplate.opsForList();
+ Long remove = listOps.remove(key, 0, valueToRemove);
+ return remove;
+ }
+
+ /**
* 鑾峰緱缂撳瓨鐨勫熀鏈璞″垪琛�
*
* @param pattern 瀛楃涓插墠缂�
--
Gitblit v1.9.3