jediscluster集群配置文件写法

jediscluster集群配置文件写法


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 jedisClusterNodes = new HashSet<>();

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信