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.
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, :)
Aucun commentaire:
Enregistrer un commentaire