Spring整合集群

package test;

import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

public class TestCluster {
    @Test
    public void testCluster(){
        Set nodes=new HashSet();
        String ip="192.168.161.135";
        nodes.add(new HostAndPort(ip, 7000));
        nodes.add(new HostAndPort(ip, 7001));
        nodes.add(new HostAndPort(ip, 7002));
        nodes.add(new HostAndPort(ip, 7003));
        nodes.add(new HostAndPort(ip, 7004));
        nodes.add(new HostAndPort(ip, 7005));
        nodes.add(new HostAndPort(ip, 7006));
        nodes.add(new HostAndPort(ip, 7007));
        nodes.add(new HostAndPort(ip, 7008));
        JedisCluster jedisCluster=new JedisCluster(nodes);
        jedisCluster.set("aa", "小集群");
        System.out.println(jedisCluster.get("aa"));
        jedisCluster.close();
    }
}

你可能感兴趣的:(Spring整合集群)