Reputation: 5933
I want to use Spring Data Redis with my clustered setup of Redis.
Now in a pure code of Jedis to connect to the cluster of Redis nodes we have to do like:
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("10.7.2.242", 7003));
jedisClusterNodes.add(new HostAndPort("10.7.2.242", 7004));
jedisClusterNodes.add(new HostAndPort("10.7.2.242", 7005));
System.out.println("jcn set initialised");
JedisCluster jc = new JedisCluster(jedisClusterNodes);
jc.set("foo_first", "bar");
String value = jc.get("foo_first");
System.out.println(value);
This outputs to bar
which is correct.
Here it is quite clear that in order to use the cluster of Redis via Jedis, we have to provide all the Ip's and Port's of the master nodes of Redis Cluster.
Now when coming to Spring backed Redis, we have some of the options, like,
JedisConnection
JedisConnectionFactory
RedisTemplate
but in reality none of these classes gives me an opportunity to give the list of Ips with ports as in the above example we gave.
Did I missed something or is there a way of handling the Redis cluster in Spring Data, also as far as I know, Sentinel and Cluster (Correct me if I am wrong) are different in their practical implementation aspect, so please don't provide the examples of Sentinels.
Thanks in advance, :)
Upvotes: 3
Views: 8126
Reputation: 905
Spring session has extended support for redis clusters now starting 1.7.1. Please refer latest reference document.
Upvotes: 5
Reputation: 418
Support for Redis 3.0 clusters has not been integrated into spring-data-redis. The Jira ticket DATAREDIS-315 was created to track this request. It seems like cluster capability was not exposed through the JedisConnection/JedisConnectionFactory classes used by Spring so it may be a while before you see this feature done.
Upvotes: 5