Databases Reference
In-Depth Information
The source code of the redisTemplate() method is given as follows:
@Bean
public RedisTemplate redisTemplate() {
RedisTemplate<String, String> redisTemplate = new
RedisTemplate<String, String>();
redisTemplate.setConnectionFactory(redisConnectionFactory());
return redisTemplate;
}
Configuring the cache manager bean
Our last step is to configure the cache manager bean. We can do this by adding the
cacheManager() method to the ApplicationContext class and annotating this
method with the @Bean annotation. We can implement this method by following
these steps:
1.
Create a new RedisCacheManager object and provide the used Redis
template as a constructor parameter.
2.
Return the created object.
The source code of the cacheManager() method is given as follows:
@Bean
public RedisCacheManager cacheManager() {
return new RedisCacheManager(redisTemplate());
}
Identifying the cached methods
We have now configured the Spring cache abstraction and we are ready to identify
the cached methods. This subsection describes how we can add contact information
in the cache, update contact information that is already stored in the cache, and
delete the contact information from the cache.
 
Search WWH ::




Custom Search