//Connect to a Redis cluster@Test Public voidTestjediscluster () {jedispoolconfig config=NewJedispoolconfig (); //Maximum number of connectionsConfig.setmaxtotal (30); //Maximum number of connection idleConfig.setmaxidle (2); //cluster NodesSetNewHashset(); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7001)); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7002)); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7003)); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7004)); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7005)); Jedisclusternode.add (NewHostandport ("192.168.101.3", 7006)); Jediscluster JC=Newjediscluster (jedisclusternode, config); Jediscluster JCD=NewJediscluster (Jedisclusternode); Jcd.set ("Name", "Zhangsan"); String value= Jcd.get ("name"); System.out.println (value); }
Java Operating Redis cluster