五 、redis-cluster java api

@Test 

public void testJedisRedisCluster(){ 

//创建集合封装集群的节点 
  Set<HostAndPort> nodes = new HashSet<HostAndPort>(); 
  nodes.add(new HostAndPort("192.168.81.142",7001)); 
  nodes.add(new HostAndPort("192.168.81.142",7002)); 
  nodes.add(new HostAndPort("192.168.81.142",7003)); 
  nodes.add(new HostAndPort("192.168.81.142",7004)); 
  nodes.add(new HostAndPort("192.168.81.142",7005)); 
  nodes.add(new HostAndPort("192.168.81.142",7006)); 
 //创建连接集群的对象 
 JedisCluster cluster = new JedisCluster(nodes); 
 System.out.println(cluster.get("name")); 
 //释放连接 
  cluster.close();
  }

猜你喜欢

转载自www.cnblogs.com/JBLi/p/11375719.html