在上一节我介绍了如何搭建redis哨兵模式,那么这一节我接着介绍使用jedis来连接操作哨兵模式下的redis。连接redis不是直接连接的master的ip,而是来连接的哨兵们,把哨兵ip放在set集合中作为参数来创建连接池,内部会获取到当前master。
@Test
public void testSentinel() {
String masterName = "mymaster";
String password = "";
// 设置参数
JedisPoolConfig jedisPoolConfig = n