Configuring Spring Data Redis with Lettuce for Redis master/slave

家住魔仙堡 提交于 2019-12-24 08:03:08

问题


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?


回答1:


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.SLAVE)
                                                    .build();

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

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



来源:https://stackoverflow.com/questions/47875258/configuring-spring-data-redis-with-lettuce-for-redis-master-slave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!