Jedis连接集群
Posted ericz2j
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jedis连接集群相关的知识,希望对你有一定的参考价值。
以maven项目为例:
1.配置pom.xml:
<dependencies> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>3.0.1</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies>
2.主类:
public class RedisCluster public static void main(String[] args) Set<HostAndPort> jedisClusterSet = new HashSet<HostAndPort>(); jedisClusterSet.add(new HostAndPort("192.168.3.216", 6379)); JedisCluster jedisCluster = new JedisCluster(jedisClusterSet); jedisCluster.set("g", "gggg"); jedisCluster.lpush("h", "111","222","333","444"); System.out.println(jedisCluster.get("151"));
以上是关于Jedis连接集群的主要内容,如果未能解决你的问题,请参考以下文章
通过jedis连接redis单机成功,使用redis客户端可以连接集群,但使用JedisCluster连接redis集群一直报Could not get a resource from the poo
Java操作redis客户端Jedis连接集群(Cluster)