John Russell
John Russell

Reputation: 1165

Does Spring's JedisConnectionFactory support the new JedisCluster?

We are migrating our Redis stack over to Redis Cluster.

In portions of our application, this has meant that we have had to replace the Jedis object with the JedisCluster object.

In our Spring client, we use the JedisConnectionFactory to persist sessions to redis. However, this class does not appear to support JedisCluster.

Any thoughts on how one would go about wiring up a Spring application to a Redis Cluster?

I noticed that this factory implements RedisConnectionFactory which requires an instance of RedisConnection to be returned. However, this assumes that only one connection to a Redis server would be required, which is not the case in RedisCluster (it takes a set of redis servers and creates connections for all of them). As a result, I am not sure what interfaces one would need to implement in order to bring Spring into our new stack.

Any help would be greatly appreciated. Thanks!

Upvotes: 5

Views: 1739

Answers (2)

mp911de
mp911de

Reputation: 18119

Spring Data Redis 1.7 will support Redis Cluster using the Jedis and the lettuce driver. Release-Date ETA first of April 2016.

Code samples for Spring Data Redis Cluster are already online: https://github.com/spring-projects/spring-data-examples/tree/master/redis/cluster

Upvotes: 0

ybonda
ybonda

Reputation: 1710

Operate through Sentinel:

>     /**  * jedis  */ @Bean public RedisConnectionFactory jedisConnectionFactory() {   RedisSentinelConfiguration sentinelConfig
> = new RedisSentinelConfiguration() .master("mymaster")   .sentinel("127.0.0.1", 26379) .sentinel("127.0.0.1", 26380);   return
> new JedisConnectionFactory(sentinelConfig); }

http://docs.spring.io/spring-data/redis/docs/current/reference/html/#redis:sentinel

Upvotes: -2

Related Questions