From 5764befa4675152bd6d1879a7ab0686eb16da18d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 27 一月 2022 11:20:54 +0800
Subject: [PATCH] update 优化 redisson 配置 去除掉不常用的配置 使用默认配置
---
ruoyi-admin/src/main/resources/application-prod.yml | 6 ---
ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java | 27 ++-----------
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java | 40 --------------------
ruoyi-admin/src/main/resources/application-dev.yml | 6 ---
4 files changed, 4 insertions(+), 75 deletions(-)
diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml
index 8fa332c..635cfea 100644
--- a/ruoyi-admin/src/main/resources/application-dev.yml
+++ b/ruoyi-admin/src/main/resources/application-dev.yml
@@ -150,11 +150,5 @@
retryAttempts: 3
# 鍛戒护閲嶈瘯鍙戦�佹椂闂撮棿闅旓紝鍗曚綅锛氭绉�
retryInterval: 1500
- # 鍙戝竷鍜岃闃呰繛鎺ョ殑鏈�灏忕┖闂茶繛鎺ユ暟
- subscriptionConnectionMinimumIdleSize: 1
# 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬
subscriptionConnectionPoolSize: 50
- # 鍗曚釜杩炴帴鏈�澶ц闃呮暟閲�
- subscriptionsPerConnection: 5
- # DNS鐩戞祴鏃堕棿闂撮殧锛屽崟浣嶏細姣
- dnsMonitoringInterval: 5000
diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml
index cfa8c7c..596c64e 100644
--- a/ruoyi-admin/src/main/resources/application-prod.yml
+++ b/ruoyi-admin/src/main/resources/application-prod.yml
@@ -157,11 +157,5 @@
retryAttempts: 3
# 鍛戒护閲嶈瘯鍙戦�佹椂闂撮棿闅旓紝鍗曚綅锛氭绉�
retryInterval: 1500
- # 鍙戝竷鍜岃闃呰繛鎺ョ殑鏈�灏忕┖闂茶繛鎺ユ暟
- subscriptionConnectionMinimumIdleSize: 1
# 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬
subscriptionConnectionPoolSize: 50
- # 鍗曚釜杩炴帴鏈�澶ц闃呮暟閲�
- subscriptionsPerConnection: 5
- # DNS鐩戞祴鏃堕棿闂撮殧锛屽崟浣嶏細姣
- dnsMonitoringInterval: 5000
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
index 6fa54e2..a8bec41 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
@@ -11,15 +11,14 @@
import org.redisson.spring.cache.CacheConfig;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -44,9 +43,9 @@
@Autowired
private RedissonProperties redissonProperties;
+ @Primary
@Bean(destroyMethod = "shutdown")
- @ConditionalOnMissingBean(RedissonClient.class)
- public RedissonClient redisson() throws IOException {
+ public RedissonClient redisson() {
String prefix = REDIS_PROTOCOL_PREFIX;
if (redisProperties.isSsl()) {
prefix = REDISS_PROTOCOL_PREFIX;
@@ -68,14 +67,11 @@
.setTimeout(singleServerConfig.getTimeout())
.setRetryAttempts(singleServerConfig.getRetryAttempts())
.setRetryInterval(singleServerConfig.getRetryInterval())
- .setSubscriptionsPerConnection(singleServerConfig.getSubscriptionsPerConnection())
.setClientName(singleServerConfig.getClientName())
.setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout())
- .setSubscriptionConnectionMinimumIdleSize(singleServerConfig.getSubscriptionConnectionMinimumIdleSize())
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
- .setConnectionPoolSize(singleServerConfig.getConnectionPoolSize())
- .setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval());
+ .setConnectionPoolSize(singleServerConfig.getConnectionPoolSize());
}
// 闆嗙兢閰嶇疆鏂瑰紡 鍙傝�冧笅鏂规敞閲�
RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig();
@@ -93,19 +89,14 @@
.setTimeout(clusterServersConfig.getTimeout())
.setRetryAttempts(clusterServersConfig.getRetryAttempts())
.setRetryInterval(clusterServersConfig.getRetryInterval())
- .setSubscriptionsPerConnection(clusterServersConfig.getSubscriptionsPerConnection())
.setClientName(clusterServersConfig.getClientName())
.setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout())
.setPingConnectionInterval(clusterServersConfig.getPingConnectionInterval())
- .setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize())
.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize())
.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize())
.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize())
.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize())
.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize())
- .setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval())
- .setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval())
- .setScanInterval(clusterServersConfig.getScanInterval())
.setReadMode(clusterServersConfig.getReadMode())
.setSubscriptionMode(clusterServersConfig.getSubscriptionMode())
.setNodeAddresses(nodes);
@@ -177,18 +168,8 @@
* retryAttempts: 3
* # 鍛戒护閲嶈瘯鍙戦�佹椂闂撮棿闅旓紝鍗曚綅锛氭绉�
* retryInterval: 1500
- * # 浠庡彲鐢ㄦ湇鍔″櫒鐨勫唴閮ㄥ垪琛ㄤ腑鎺掗櫎 Redis Slave 閲嶆柊杩炴帴灏濊瘯鐨勯棿闅斻��
- * failedSlaveReconnectionInterval: 3000
- * # 鍙戝竷鍜岃闃呰繛鎺ユ睜鏈�灏忕┖闂茶繛鎺ユ暟
- * subscriptionConnectionMinimumIdleSize: 1
* # 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬
* subscriptionConnectionPoolSize: 50
- * # 鍗曚釜杩炴帴鏈�澶ц闃呮暟閲�
- * subscriptionsPerConnection: 5
- * # 鎵弿闂撮殧
- * scanInterval: 1000
- * # DNS鐩戞祴鏃堕棿闂撮殧锛屽崟浣嶏細姣
- * dnsMonitoringInterval: 5000
* # 璇诲彇妯″紡
* readMode: "SLAVE"
* # 璁㈤槄妯″紡
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java
index 0b9024d..eae9e3f 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java
@@ -90,24 +90,9 @@
private int retryInterval;
/**
- * 鍙戝竷鍜岃闃呰繛鎺ョ殑鏈�灏忕┖闂茶繛鎺ユ暟
- */
- private int subscriptionConnectionMinimumIdleSize;
-
- /**
* 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬
*/
private int subscriptionConnectionPoolSize;
-
- /**
- * 鍗曚釜杩炴帴鏈�澶ц闃呮暟閲�
- */
- private int subscriptionsPerConnection;
-
- /**
- * DNS鐩戞祴鏃堕棿闂撮殧锛屽崟浣嶏細姣
- */
- private int dnsMonitoringInterval;
}
@@ -166,34 +151,9 @@
private int retryInterval;
/**
- * 閿欒閲嶈瘯娆℃暟
- */
- private int failedSlaveReconnectionInterval;
-
- /**
- * 鍙戝竷鍜岃闃呰繛鎺ユ睜鏈�灏忕┖闂茶繛鎺ユ暟
- */
- private int subscriptionConnectionMinimumIdleSize;
-
- /**
* 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬
*/
private int subscriptionConnectionPoolSize;
-
- /**
- * 鍗曚釜杩炴帴鏈�澶ц闃呮暟閲�
- */
- private int subscriptionsPerConnection;
-
- /**
- * 鎵弿闂撮殧
- */
- private int scanInterval;
-
- /**
- * DNS鐩戞祴鏃堕棿闂撮殧锛屽崟浣嶏細姣
- */
- private int dnsMonitoringInterval;
/**
* 璇诲彇妯″紡
--
Gitblit v1.9.3