Skip to content

Instantly share code, notes, and snippets.

@debop
Created March 26, 2013 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save debop/5243830 to your computer and use it in GitHub Desktop.
Save debop/5243830 to your computer and use it in GitHub Desktop.
@Configuration
@EnableCaching
@ComponentScan(basePackageClasses = UserRepository.class)
// @PropertySource("classpath:redis.properties")
public class RedisCacheConfiguration {
@Autowired
Environment env;
@Bean
public JedisShardInfo jedisShardInfo() {
return new JedisShardInfo("localhost");
}
@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory(jedisShardInfo());
}
@Bean
public RedisTemplate redisTemplate() {
RedisTemplate<String,Object> template = new RedisTemplate<String,Object>();
template.setConnectionFactory(redisConnectionFactory());
return template;
}
@Bean
public RedisCacheManager redisCacheManager() {
return new RedisCacheManager(redisTemplate(), 300);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment