五 、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(); }
作为一个真正的程序员,首先应该尊重编程,热爱你所写下的程序,他是你的伙伴,而不是工具。