Pre Merge pull request !682 from 隼龙/dev
This commit is contained in:
commit
bb40d2cb5a
@ -112,24 +112,26 @@ spring.data:
|
|||||||
|
|
||||||
# redisson 配置
|
# redisson 配置
|
||||||
redisson:
|
redisson:
|
||||||
|
# 模式 org.dromara.common.redis.Model
|
||||||
|
model: SINGLE
|
||||||
# redis key前缀
|
# redis key前缀
|
||||||
keyPrefix:
|
keyPrefix:
|
||||||
# 线程池数量
|
# 线程池数量
|
||||||
threads: 4
|
threads: 4
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
nettyThreads: 8
|
nettyThreads: 8
|
||||||
# 单节点配置
|
|
||||||
singleServerConfig:
|
|
||||||
# 客户端名称 不能用中文
|
# 客户端名称 不能用中文
|
||||||
clientName: RuoYi-Vue-Plus
|
clientName: RuoYi-Vue-Plus
|
||||||
# 最小空闲连接数
|
|
||||||
connectionMinimumIdleSize: 8
|
|
||||||
# 连接池大小
|
|
||||||
connectionPoolSize: 32
|
|
||||||
# 连接空闲超时,单位:毫秒
|
# 连接空闲超时,单位:毫秒
|
||||||
idleConnectionTimeout: 10000
|
idleConnectionTimeout: 10000
|
||||||
# 命令等待超时,单位:毫秒
|
# 命令等待超时,单位:毫秒
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
|
# 单节点配置
|
||||||
|
singleServerConfig:
|
||||||
|
# 最小空闲连接数
|
||||||
|
connectionMinimumIdleSize: 8
|
||||||
|
# 连接池大小
|
||||||
|
connectionPoolSize: 32
|
||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
|
||||||
|
@ -115,24 +115,26 @@ spring.data:
|
|||||||
|
|
||||||
# redisson 配置
|
# redisson 配置
|
||||||
redisson:
|
redisson:
|
||||||
|
# 模式 org.dromara.common.redis.Model
|
||||||
|
model: SINGLE
|
||||||
# redis key前缀
|
# redis key前缀
|
||||||
keyPrefix:
|
keyPrefix:
|
||||||
# 线程池数量
|
# 线程池数量
|
||||||
threads: 16
|
threads: 16
|
||||||
# Netty线程池数量
|
# Netty线程池数量
|
||||||
nettyThreads: 32
|
nettyThreads: 32
|
||||||
# 单节点配置
|
|
||||||
singleServerConfig:
|
|
||||||
# 客户端名称 不能用中文
|
# 客户端名称 不能用中文
|
||||||
clientName: RuoYi-Vue-Plus
|
clientName: RuoYi-Vue-Plus
|
||||||
# 最小空闲连接数
|
|
||||||
connectionMinimumIdleSize: 32
|
|
||||||
# 连接池大小
|
|
||||||
connectionPoolSize: 64
|
|
||||||
# 连接空闲超时,单位:毫秒
|
# 连接空闲超时,单位:毫秒
|
||||||
idleConnectionTimeout: 10000
|
idleConnectionTimeout: 10000
|
||||||
# 命令等待超时,单位:毫秒
|
# 命令等待超时,单位:毫秒
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
|
# 单节点配置
|
||||||
|
singleServerConfig:
|
||||||
|
# 最小空闲连接数
|
||||||
|
connectionMinimumIdleSize: 32
|
||||||
|
# 连接池大小
|
||||||
|
connectionPoolSize: 64
|
||||||
# 发布和订阅连接池大小
|
# 发布和订阅连接池大小
|
||||||
subscriptionConnectionPoolSize: 50
|
subscriptionConnectionPoolSize: 50
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.common.redis;
|
||||||
|
|
||||||
|
public enum Model {
|
||||||
|
|
||||||
|
//单例
|
||||||
|
SINGLE,
|
||||||
|
//集群
|
||||||
|
CLUSTER,
|
||||||
|
//哨兵
|
||||||
|
SENTINEL,
|
||||||
|
//主从
|
||||||
|
MASTER_SLAVE,
|
||||||
|
//云托管模式
|
||||||
|
REPLICATED
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package org.dromara.common.redis.config;
|
package org.dromara.common.redis.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@ -16,12 +15,17 @@ import org.dromara.common.redis.handler.RedisExceptionHandler;
|
|||||||
import org.redisson.client.codec.StringCodec;
|
import org.redisson.client.codec.StringCodec;
|
||||||
import org.redisson.codec.CompositeCodec;
|
import org.redisson.codec.CompositeCodec;
|
||||||
import org.redisson.codec.TypedJsonJacksonCodec;
|
import org.redisson.codec.TypedJsonJacksonCodec;
|
||||||
|
import org.redisson.config.MasterSlaveServersConfig;
|
||||||
|
import org.redisson.config.ReplicatedServersConfig;
|
||||||
|
import org.redisson.config.SentinelServersConfig;
|
||||||
|
import org.redisson.connection.balancer.LoadBalancer;
|
||||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@ -68,27 +72,28 @@ public class RedisConfig {
|
|||||||
config.setNettyExecutor(new VirtualThreadTaskExecutor("redisson-"));
|
config.setNettyExecutor(new VirtualThreadTaskExecutor("redisson-"));
|
||||||
}
|
}
|
||||||
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
|
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
|
||||||
if (ObjectUtil.isNotNull(singleServerConfig)) {
|
// 集群配置方式 参考下方注释
|
||||||
|
RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig();
|
||||||
|
switch (redissonProperties.getModel()){
|
||||||
|
case SINGLE:
|
||||||
// 使用单机模式
|
// 使用单机模式
|
||||||
config.useSingleServer()
|
config.useSingleServer()
|
||||||
//设置redis key前缀
|
//设置redis key前缀
|
||||||
.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()))
|
.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()))
|
||||||
.setTimeout(singleServerConfig.getTimeout())
|
.setTimeout(redissonProperties.getTimeout())
|
||||||
.setClientName(singleServerConfig.getClientName())
|
.setClientName(redissonProperties.getClientName())
|
||||||
.setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout())
|
.setIdleConnectionTimeout(redissonProperties.getIdleConnectionTimeout())
|
||||||
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
|
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
|
||||||
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
|
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
|
||||||
.setConnectionPoolSize(singleServerConfig.getConnectionPoolSize());
|
.setConnectionPoolSize(singleServerConfig.getConnectionPoolSize());
|
||||||
}
|
break;
|
||||||
// 集群配置方式 参考下方注释
|
case CLUSTER:
|
||||||
RedissonProperties.ClusterServersConfig clusterServersConfig = redissonProperties.getClusterServersConfig();
|
|
||||||
if (ObjectUtil.isNotNull(clusterServersConfig)) {
|
|
||||||
config.useClusterServers()
|
config.useClusterServers()
|
||||||
//设置redis key前缀
|
//设置redis key前缀
|
||||||
.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()))
|
.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()))
|
||||||
.setTimeout(clusterServersConfig.getTimeout())
|
.setTimeout(redissonProperties.getTimeout())
|
||||||
.setClientName(clusterServersConfig.getClientName())
|
.setClientName(redissonProperties.getClientName())
|
||||||
.setIdleConnectionTimeout(clusterServersConfig.getIdleConnectionTimeout())
|
.setIdleConnectionTimeout(redissonProperties.getIdleConnectionTimeout())
|
||||||
.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize())
|
.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize())
|
||||||
.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize())
|
.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize())
|
||||||
.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize())
|
.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize())
|
||||||
@ -96,11 +101,111 @@ public class RedisConfig {
|
|||||||
.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize())
|
.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize())
|
||||||
.setReadMode(clusterServersConfig.getReadMode())
|
.setReadMode(clusterServersConfig.getReadMode())
|
||||||
.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
||||||
|
break;
|
||||||
|
case SENTINEL:
|
||||||
|
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
|
||||||
|
sentinelServersConfig.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()));
|
||||||
|
sentinelServersConfig.setDatabase(clusterServersConfig.getDatabase());
|
||||||
|
sentinelServersConfig.setMasterName(clusterServersConfig.getMasterName());
|
||||||
|
sentinelServersConfig.setScanInterval(clusterServersConfig.getScanInterval());
|
||||||
|
sentinelServersConfig.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize());
|
||||||
|
sentinelServersConfig.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize());
|
||||||
|
sentinelServersConfig.setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval());
|
||||||
|
sentinelServersConfig.setFailedSlaveCheckInterval(clusterServersConfig.getFailedSlaveCheckInterval());
|
||||||
|
sentinelServersConfig.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize());
|
||||||
|
sentinelServersConfig.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize());
|
||||||
|
sentinelServersConfig.setReadMode(clusterServersConfig.getReadMode());
|
||||||
|
sentinelServersConfig.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
||||||
|
sentinelServersConfig.setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize());
|
||||||
|
sentinelServersConfig.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize());
|
||||||
|
sentinelServersConfig.setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval());
|
||||||
|
try {
|
||||||
|
sentinelServersConfig.setLoadBalancer((LoadBalancer) Class.forName(clusterServersConfig.getLoadBalancer()).newInstance());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
for (String nodeAddress : clusterServersConfig.getNodeAddresses()) {
|
||||||
|
sentinelServersConfig.addSentinelAddress(prefixAddress(nodeAddress));
|
||||||
|
}
|
||||||
|
sentinelServersConfig.setClientName(redissonProperties.getClientName());
|
||||||
|
sentinelServersConfig.setConnectTimeout(redissonProperties.getConnectTimeout());
|
||||||
|
sentinelServersConfig.setIdleConnectionTimeout(redissonProperties.getIdleConnectionTimeout());
|
||||||
|
sentinelServersConfig.setTimeout(redissonProperties.getTimeout());
|
||||||
|
break;
|
||||||
|
case MASTER_SLAVE:
|
||||||
|
MasterSlaveServersConfig masterSlaveServersConfig = config.useMasterSlaveServers();
|
||||||
|
masterSlaveServersConfig.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()));
|
||||||
|
masterSlaveServersConfig.setDatabase(clusterServersConfig.getDatabase());
|
||||||
|
masterSlaveServersConfig.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize());
|
||||||
|
masterSlaveServersConfig.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize());
|
||||||
|
masterSlaveServersConfig.setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval());
|
||||||
|
masterSlaveServersConfig.setFailedSlaveCheckInterval(clusterServersConfig.getFailedSlaveCheckInterval());
|
||||||
|
masterSlaveServersConfig.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize());
|
||||||
|
masterSlaveServersConfig.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize());
|
||||||
|
masterSlaveServersConfig.setReadMode(clusterServersConfig.getReadMode());
|
||||||
|
masterSlaveServersConfig.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
||||||
|
masterSlaveServersConfig.setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize());
|
||||||
|
masterSlaveServersConfig.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize());
|
||||||
|
masterSlaveServersConfig.setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval());
|
||||||
|
try {
|
||||||
|
masterSlaveServersConfig.setLoadBalancer((LoadBalancer) Class.forName(clusterServersConfig.getLoadBalancer()).newInstance());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
int index=0;
|
||||||
|
for (String nodeAddress : clusterServersConfig.getNodeAddresses()) {
|
||||||
|
if(index++==0){
|
||||||
|
masterSlaveServersConfig.setMasterAddress(prefixAddress(nodeAddress));
|
||||||
|
}else{
|
||||||
|
masterSlaveServersConfig.addSlaveAddress(prefixAddress(nodeAddress));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
masterSlaveServersConfig.setClientName(redissonProperties.getClientName());
|
||||||
|
masterSlaveServersConfig.setConnectTimeout(redissonProperties.getConnectTimeout());
|
||||||
|
masterSlaveServersConfig.setIdleConnectionTimeout(redissonProperties.getIdleConnectionTimeout());
|
||||||
|
masterSlaveServersConfig.setTimeout(redissonProperties.getTimeout());
|
||||||
|
break;
|
||||||
|
case REPLICATED:
|
||||||
|
ReplicatedServersConfig replicatedServersConfig = config.useReplicatedServers();
|
||||||
|
replicatedServersConfig.setNameMapper(new KeyPrefixHandler(redissonProperties.getKeyPrefix()));
|
||||||
|
replicatedServersConfig.setDatabase(clusterServersConfig.getDatabase());
|
||||||
|
replicatedServersConfig.setScanInterval(clusterServersConfig.getScanInterval());
|
||||||
|
replicatedServersConfig.setSlaveConnectionMinimumIdleSize(clusterServersConfig.getSlaveConnectionMinimumIdleSize());
|
||||||
|
replicatedServersConfig.setSlaveConnectionPoolSize(clusterServersConfig.getSlaveConnectionPoolSize());
|
||||||
|
replicatedServersConfig.setFailedSlaveReconnectionInterval(clusterServersConfig.getFailedSlaveReconnectionInterval());
|
||||||
|
replicatedServersConfig.setFailedSlaveCheckInterval(clusterServersConfig.getFailedSlaveCheckInterval());
|
||||||
|
replicatedServersConfig.setMasterConnectionMinimumIdleSize(clusterServersConfig.getMasterConnectionMinimumIdleSize());
|
||||||
|
replicatedServersConfig.setMasterConnectionPoolSize(clusterServersConfig.getMasterConnectionPoolSize());
|
||||||
|
replicatedServersConfig.setReadMode(clusterServersConfig.getReadMode());
|
||||||
|
replicatedServersConfig.setSubscriptionMode(clusterServersConfig.getSubscriptionMode());
|
||||||
|
replicatedServersConfig.setSubscriptionConnectionMinimumIdleSize(clusterServersConfig.getSubscriptionConnectionMinimumIdleSize());
|
||||||
|
replicatedServersConfig.setSubscriptionConnectionPoolSize(clusterServersConfig.getSubscriptionConnectionPoolSize());
|
||||||
|
replicatedServersConfig.setDnsMonitoringInterval(clusterServersConfig.getDnsMonitoringInterval());
|
||||||
|
try {
|
||||||
|
replicatedServersConfig.setLoadBalancer((LoadBalancer) Class.forName(clusterServersConfig.getLoadBalancer()).newInstance());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
for (String nodeAddress : clusterServersConfig.getNodeAddresses()) {
|
||||||
|
replicatedServersConfig.addNodeAddress(prefixAddress(nodeAddress));
|
||||||
|
}
|
||||||
|
replicatedServersConfig.setClientName(redissonProperties.getClientName());
|
||||||
|
replicatedServersConfig.setConnectTimeout(redissonProperties.getConnectTimeout());
|
||||||
|
replicatedServersConfig.setIdleConnectionTimeout(redissonProperties.getIdleConnectionTimeout());
|
||||||
|
replicatedServersConfig.setTimeout(redissonProperties.getTimeout());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
log.info("初始化 redis 配置");
|
log.info("初始化 redis 配置");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String prefixAddress(String address){
|
||||||
|
if(!StringUtils.isEmpty(address)&&!address.startsWith("redis")){
|
||||||
|
return "redis://"+address;
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异常处理器
|
* 异常处理器
|
||||||
*/
|
*/
|
||||||
@ -134,6 +239,10 @@ public class RedisConfig {
|
|||||||
* nettyThreads: 32
|
* nettyThreads: 32
|
||||||
* # 集群配置
|
* # 集群配置
|
||||||
* clusterServersConfig:
|
* clusterServersConfig:
|
||||||
|
* node-addresses:
|
||||||
|
* - 127.0.0.1:6379
|
||||||
|
* - 127.0.0.1:6380
|
||||||
|
* - 127.0.0.1:6381
|
||||||
* # 客户端名称
|
* # 客户端名称
|
||||||
* clientName: ${ruoyi.name}
|
* clientName: ${ruoyi.name}
|
||||||
* # master最小空闲连接数
|
* # master最小空闲连接数
|
||||||
@ -154,6 +263,9 @@ public class RedisConfig {
|
|||||||
* readMode: "SLAVE"
|
* readMode: "SLAVE"
|
||||||
* # 订阅模式
|
* # 订阅模式
|
||||||
* subscriptionMode: "MASTER"
|
* subscriptionMode: "MASTER"
|
||||||
|
* #单Redis节点模式
|
||||||
|
* singleServerConfig:
|
||||||
|
* address: 127.0.0.1:6379
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,14 @@ package org.dromara.common.redis.config.properties;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.dromara.common.redis.Model;
|
||||||
import org.redisson.config.ReadMode;
|
import org.redisson.config.ReadMode;
|
||||||
import org.redisson.config.SubscriptionMode;
|
import org.redisson.config.SubscriptionMode;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redisson 配置属性
|
* Redisson 配置属性
|
||||||
*
|
*
|
||||||
@ -15,6 +19,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||||||
@ConfigurationProperties(prefix = "redisson")
|
@ConfigurationProperties(prefix = "redisson")
|
||||||
public class RedissonProperties {
|
public class RedissonProperties {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 模式
|
||||||
|
*/
|
||||||
|
private Model model= Model.SINGLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis缓存key前缀
|
* redis缓存key前缀
|
||||||
*/
|
*/
|
||||||
@ -30,6 +39,27 @@ public class RedissonProperties {
|
|||||||
*/
|
*/
|
||||||
private int nettyThreads;
|
private int nettyThreads;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接空闲超时,单位:毫秒
|
||||||
|
*/
|
||||||
|
private int idleConnectionTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 命令等待超时,单位:毫秒
|
||||||
|
*/
|
||||||
|
private int timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端名称
|
||||||
|
*/
|
||||||
|
private String clientName;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 连接超时,单位:毫秒
|
||||||
|
*/
|
||||||
|
private Integer connectTimeout = 10000;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单机服务配置
|
* 单机服务配置
|
||||||
*/
|
*/
|
||||||
@ -44,10 +74,6 @@ public class RedissonProperties {
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class SingleServerConfig {
|
public static class SingleServerConfig {
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端名称
|
|
||||||
*/
|
|
||||||
private String clientName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最小空闲连接数
|
* 最小空闲连接数
|
||||||
@ -59,16 +85,6 @@ public class RedissonProperties {
|
|||||||
*/
|
*/
|
||||||
private int connectionPoolSize;
|
private int connectionPoolSize;
|
||||||
|
|
||||||
/**
|
|
||||||
* 连接空闲超时,单位:毫秒
|
|
||||||
*/
|
|
||||||
private int idleConnectionTimeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 命令等待超时,单位:毫秒
|
|
||||||
*/
|
|
||||||
private int timeout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布和订阅连接池大小
|
* 发布和订阅连接池大小
|
||||||
*/
|
*/
|
||||||
@ -80,10 +96,6 @@ public class RedissonProperties {
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class ClusterServersConfig {
|
public static class ClusterServersConfig {
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端名称
|
|
||||||
*/
|
|
||||||
private String clientName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* master最小空闲连接数
|
* master最小空闲连接数
|
||||||
@ -105,31 +117,72 @@ public class RedissonProperties {
|
|||||||
*/
|
*/
|
||||||
private int slaveConnectionPoolSize;
|
private int slaveConnectionPoolSize;
|
||||||
|
|
||||||
/**
|
|
||||||
* 连接空闲超时,单位:毫秒
|
|
||||||
*/
|
|
||||||
private int idleConnectionTimeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 命令等待超时,单位:毫秒
|
|
||||||
*/
|
|
||||||
private int timeout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布和订阅连接池大小
|
* 发布和订阅连接池大小
|
||||||
*/
|
*/
|
||||||
private int subscriptionConnectionPoolSize;
|
private int subscriptionConnectionPoolSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取模式
|
* 设置读取操作选择节点的模式。
|
||||||
|
* SLAVE - 只在从服务节点里读取。
|
||||||
|
* MASTER - 只在主服务节点里读取。
|
||||||
|
* MASTER_SLAVE - 在主从服务节点里都可以读取
|
||||||
*/
|
*/
|
||||||
private ReadMode readMode;
|
private ReadMode readMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订阅模式
|
* 设置订阅操作选择节点的模式。
|
||||||
|
* SLAVE - 只在从服务节点里订阅。
|
||||||
|
* MASTER - 只在主服务节点里订阅
|
||||||
*/
|
*/
|
||||||
private SubscriptionMode subscriptionMode;
|
private SubscriptionMode subscriptionMode;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 负载均衡方式
|
||||||
|
*/
|
||||||
|
private String loadBalancer = "org.redisson.connection.balancer.RoundRobinLoadBalancer";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 订阅连接失败重连间隔时间
|
||||||
|
*/
|
||||||
|
private Integer failedSlaveReconnectionInterval = 3000;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 订阅连接空闲超时
|
||||||
|
*/
|
||||||
|
private Integer failedSlaveCheckInterval = 180000;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 用于发布和订阅连接的最小保持连接数(长连接)
|
||||||
|
*/
|
||||||
|
private Integer subscriptionConnectionMinimumIdleSize=1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 监测DNS的变化情况的时间间隔
|
||||||
|
*/
|
||||||
|
private Long dnsMonitoringInterval=5000L;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 节点地址
|
||||||
|
*/
|
||||||
|
private List<String> nodeAddresses = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (集群,哨兵,云托管模特特有) 对Redis集群节点状态扫描的时间间隔。单位是毫秒
|
||||||
|
*/
|
||||||
|
private Integer scanInterval = 1000;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (哨兵模式,云托管,主从模式特有)尝试连接的数据库编号
|
||||||
|
*/
|
||||||
|
private Integer database = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (哨兵模式特有)主服务器的名称是哨兵进程中用来监测主从服务切换情况的
|
||||||
|
*/
|
||||||
|
private String masterName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user