Connections to multiple Redis servers with Spring Data Redis


I'm working on an application(Spring) with the following requirements:

<ul><li>Read data from Redis Server1</li> <li>Read data from Redis Server2</li> <li>Read data from Redis Server3</li> </ul>


<ul><li>Save the information to MySQL.</li> </ul>

Can someone give us a thought to connect to different Redis servers using Spring Data Redis.

Got a link: <a href="http://forum.spring.io/forum/spring-projects/data/nosql/104599-how-to-connect-to-multiple-redis-instances-using-redistemplate?view=stream" rel="nofollow">http://forum.spring.io/forum/spring-projects/data/nosql/104599-how-to-connect-to-multiple-redis-instances-using-redistemplate?view=stream</a>

But that's too old.

Any help would be appreciated.


There's not out-of-the-box support for accessing multiple servers at once but you can get there yourself.

Usually, you would use <a href="http://docs.spring.io/spring-data/data-redis/docs/current/api/org/springframework/data/redis/core/RedisTemplate.html" rel="nofollow">RedisTemplate</a> to interact with Redis. RedisTemplate uses <a href="http://docs.spring.io/spring-data/data-redis/docs/current/api/org/springframework/data/redis/connection/RedisConnectionFactory.html" rel="nofollow">RedisConnectionFactory</a> to obtain a connection per requests. You can implement RedisConnectionFactory yourself and dispatch getConnection() calls to the connection factory that is configured with your server. A Map<String, RedisConnectionFactory> can hold multiple connection factories. You would dispatch by a custom discriminator (usually something that you set on ThreadLocal level).

Spring Framework provides something similar for JDBC with <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java" rel="nofollow">AbstractRoutingDataSource</a>. The code at GitHub should give you an approach how to implement a routing RedisConnectionFactory.


  • Cloud firestore for ecommerce app.
  • How to JOIN two nodes with AngularFire2 and Firebase?
  • How to extract parameters from a URL regardless the way it written by?
  • How to extract parameters from a URL regardless the way it written by?
  • Infrastructure mobility via Onion architecture - practical implications
  • Database for Full Text Search and 200M+ Records
  • Simple Yahoo Weather Api Not Working
  • PyTorch: Relation between Dynamic Computational Graphs - Padding - DataLoader
  • unmanaged win32 dll not loading in .net MVC app on IIS 8.5, Win Server 2012 R2, Azure virtual machin
  • mysql select inside limit
  • css font-size and line-height not matching the baseline
  • Graceful pod termination
  • insert a picture into database(sqlite) with java code. what should i do?
  • Create registry key in 32-bit hive on x64 PC using Installshield 2012 LE - Avoid redirection
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • Configuring multiple DefaultJmslistenercontainerfactory
  • Does Apportable support to build library binary (.a/.so)?
  • JPA flush vs commit
  • JqueryMobile Popup menu is not working
  • What is the purpose of TaskExecutor in spring?
  • gspread or such: help me get cell coordinates (not value)
  • Webgrid not refreshing after delete MVC
  • Do I need to reset a Perl hash index?
  • Custom Tabgroup Appcelerator
  • Jquery UI tool tip close icon
  • Repeat a vertical line on every page in Report Builder / SSRS
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Projection media query: browser support and workarounds?
  • Android screen density dpi vs ppi
  • Different response to non-authenticated users and AJAX calls
  • Bug in WPF DataGrid
  • VS2008 Enable C++ Exception with SEH
  • Why winpcap requires both .lib and .dll to run?
  • Traverse Array and Display in markup
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Turn off referential integrity in Derby? is it possible?
  • Qt: Run a script BEFORE make
  • JaxB to read class hierarchy
  • java string with new operator and a literal