疯狂的狮子li
2022-01-27 5764befa4675152bd6d1879a7ab0686eb16da18d
update 优化 redisson 配置 去除掉不常用的配置 使用默认配置
已修改4个文件
79 ■■■■■ 文件已修改
ruoyi-admin/src/main/resources/application-dev.yml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-prod.yml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
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
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"
     *     # 订阅模式
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;
        /**
         * 读取模式