1. 程式人生 > >python與java中使用redis集群

python與java中使用redis集群

port conf dHash scl link redis集群 hash new art

1.python使用

from rediscluster import StrictRedisCluster

redis_nodes = [{‘host‘:‘192.168.78.62‘,‘port‘:"6380"},{‘host‘:‘192.168.78.62‘,‘port‘:"6381" }]
redis_passwd = "xxxxx"

Redis_Client = StrictRedisCluster(startup_nodes=redis_nodes,password=redis_passwd)

2.java使用

private static JedisCluster jedisPoolDB = null;

Set<HostAndPort> nodes = new LinkedHashSet<HostAndPort>();

nodes.add(new HostAndPort(Config.REDIS_IP, Config.REDIS_PORT));

jedisPoolDB = new JedisCluster(nodes, 10 * 1000, 10 * 1000, 3, Config.REDIS_PASSWORD, config);

python與java中使用redis集群