Created
March 26, 2013 08:16
-
-
Save debop/5243830 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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