Description
I have a use case like using two different regions Redis. Since the Redis is not synced between two different data centers. Need to update the data center in a synchronized fashion.
I'm facing a problem while updating the cache, The cache is updated in only one region.
@EnableRedisRepositories(basePackageClasses = {RefreshEastCacheRepository.class}, redisTemplateRef = "refreshEastRedisTemplate")
@EnableRedisRepositories(basePackageClasses = {RefreshWestCacheRepository.class}, redisTemplateRef = "refreshWestRedisTemplate")
I have configured the two different Redis in the same project and in one of the configurations I have added @primary(East Region) for the base use-case.
@repository("eastRepository")
public interface RefreshEastCacheRepository<T, D> extends CrudRepository<T, D>, QueryByExampleExecutor {
}
@repository("westRepository")
public interface RefreshWestCacheRepository<T, D> extends CrudRepository<T, D>, QueryByExampleExecutor {
}
I have Autowired the above repository in my class. When there is any update happened, the cache is updated only in the east region. but it's not updating in the west. If we use RedisTemplate we can update in the two different regions. But I feel comfortable using the repository.save method to update in the cache.
When I dig deeper into the code the container factory is the default for all the Repository and it's the same for all the Repositories.
I need a way to differentiate the two different containers at the Repository level. In the @EnableJPARepository, it allows us to add the EntityBeanFactory but in the EnableRedisRepositories we don't have an option to point out the right container factory.
Is there any better way to do that ???