python与java中使用redis集群

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);

posted @ 2019-01-06 16:23  lingwang3  阅读(301)  评论(0编辑  收藏  举报