gcpdev-guy
gcpdev-guy

Reputation: 484

Configuring Spring Data Redis with Lettuce for Redis master/slave

Using Lettuce, how do we configure Spring Data Redis running on host x at port 6379 and slave running on the same or different host but at port 6380?

Upvotes: 2

Views: 7465

Answers (1)

mp911de
mp911de

Reputation: 18119

That's a feature which will be included in the upcoming Spring Data Redis 2.1 release. You would configure LettuceConnectionFactory similar to:

    LettuceClientConfiguration configuration = LettuceClientConfiguration.builder()
                                                    .readFrom(ReadFrom.REPLICA)
                                                    .build();

    LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration("x", 6379),
                                                    configuration);

Lettuce auto-discovers masters and replicas from a static (not managed with Redis Sentinel) setup.

Upvotes: 7

Related Questions