admin 管理员组文章数量: 1086019
2024年1月17日发(作者:disty什么意思)
jediscluster集群配置文件写法
JedisCluster是Redis官方提供的Java客户端,用于连接Redis集群。JedisCluster的配置文件可以使用properties或者yaml格式,以下是两种格式的示例:
1. properties格式
```
# Redis集群节点列表
=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
# 连接池最大连接数
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(perty("al")));
Idle(nt(perty("e")));
Idle(nt(perty("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);
```
版权声明:本文标题:jediscluster集群配置文件写法 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1705480924a486539.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论