java程式測試redis叢集
阿新 • • 發佈:2018-12-25
1、啟動redis叢集
2、匯入jedis的相關jar
3、測試程式碼如下
/**
* 叢集test
* @throws Exception
*/
@Test
public void test8() throws Exception {
HashSet<HostAndPort> hashSet=new HashSet<>();
hashSet.add(new HostAndPort("123.57.36.98", 7000));
hashSet.add(new HostAndPort("123.57.36.98" , 7001));
hashSet.add(new HostAndPort("123.57.36.98", 7002));
hashSet.add(new HostAndPort("123.57.36.98", 7003));
hashSet.add(new HostAndPort("123.57.36.98", 7004));
hashSet.add(new HostAndPort("123.57.36.98", 7005));
JedisCluster jedisCluster=new JedisCluster(hashSet);
jedisCluster.set("duan" , "100");
String kString=jedisCluster.get("duan");
System.out.println(kString);
}
測試結果如下