JedisSentinelConnection是Jedis提供的一个连接Sentinel集群的连接池,可以通过以下配置进行配置:

1.连接池配置

可以通过以下方式配置连接池:

JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(10);
poolConfig.setMaxIdle(5);
poolConfig.setMinIdle(1);
poolConfig.setTestOnBorrow(true);

2.连接Sentinel配置

可以通过以下方式配置连接Sentinel集群:

Set<String> sentinels = new HashSet<String>();
sentinels.add("127.0.0.1:26379");
JedisSentinelPool jedisSentinelPool = new JedisSentinelPool("mymaster", sentinels, poolConfig);

其中,mymaster是Sentinel集群的master节点的名称。

3.连接密码配置

如果Sentinel集群需要密码进行连接,可以通过以下方式进行配置:

JedisSentinelPool jedisSentinelPool = new JedisSentinelPool("mymaster", sentinels, poolConfig, "password");

其中,password是Sentinel集群的密码。

4.连接超时配置

可以通过以下方式配置连接超时时间:

JedisSentinelPool jedisSentinelPool = new JedisSentinelPool("mymaster", sentinels, poolConfig, 1000, "password");

其中,1000表示连接超时时间,单位为毫秒

JedisSentinelConnection配置

原文地址: http://www.cveoy.top/t/topic/eHOr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录