五 、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();
  }

 

posted @ 2019-08-19 10:39  lilixia  阅读(318)  评论(0编辑  收藏  举报