I have reached a conflict situation between Spring @Repository and @Cacheable.
- I'm using @EnableCaching and have annotated a @Cacheable method. The expectation is that by default, it will create an in-memory cache without any additional configuration required.
@Service
public class ServiceA{
@Cacheable("cacheName")
public Response getResponse(){
}
}
@EnableCaching
public class SpringBootApplication {
...
}
- I have @Repository class and a configuration class @EnableRedisRepositories which performs some CRUD operations towards a Redis DB reachable in a remote IP address that does not require any caching.
@Repository
public class RedisRepository{
public void setSomething(){
}
public Something getSomething(){
}
}
@Configuration
@EnableRedisRepositories
public class RedisConfig {
@Bean
public JedisConnectionFactory connectionFactory() {
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
}
}
The case is that with that configuration, the In-Memory cache is ignored and my cache is stored in the remote Redis DB.
How can I keep the in-memory cache and don't use remote Redis for caching?