2024年4月10日发(作者:)
jediscluster集群配置文件写法
JedisCluster是Redis官方提供的Java客户端,用于连接Redis集
群。JedisCluster的配置文件可以使用properties或者yaml格式,
以下是两种格式的示例:
1. properties格式
```
# Redis集群节点列表
=192.168.1.1:6379,192.168.1.2:6379,192.1
68.1.3:6379,192.168.1.4:6379,192.168.1.5:6379,192.168.1.6:6
379
# 连接池最大连接数
al=100
# 连接池最大空闲连接数
e=50
# 连接池最小空闲连接数
e=10
# 连接超时时间
t=5000
# Redis密码
rd=123456
```
2. yaml格式
```
redis:
cluster:
nodes:
192.168.1.1:6379,192.168.1.2:6379,192.168.1.3:6379,192.168.
1.4:6379,192.168.1.5:6379,192.168.1.6:6379
pool:
maxTotal: 100
maxIdle: 50
minIdle: 10
timeout: 5000
password: 123456
```
以上两种格式的配置文件都可以通过JedisCluster的构造方法进行
加载:
```
JedisPoolConfig poolConfig = new JedisPoolConfig();
Total(nt(pe
rty("al")));
Idle(nt(per
ty("e")));
Idle(nt(per
ty("e")));
String[] nodes =
perty("").split(",");
Set
for (String node : nodes) {
String[] parts = (":");
(new
nt(parts[1])));
}
HostAndPort(parts[0],
JedisCluster jedisCluster = new
JedisCluster(jedisClusterNodes,
nt(perty("t")),
nt(perty("t")),
3, perty("rd"), poolConfig);
```
发布者:admin,转转请注明出处:http://www.yc00.com/news/1712701558a2106293.html
评论列表(0条)