参考(一)
@Configuration
public class RedisCacheConfig {
@Value("${liu.globalSessionTimeout}")
private long globalSessionTimeout;
@Autowired
ResourceLoader resourceLoader;
@Bean
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
return RedisCacheManager.builder(redisConnectionFactory)
//默认的缓存配置(没有配置键的key均使用此配置)
.cacheDefaults(getDefaultCacheConfiguration())
.withInitialCacheConfigurations(getCacheConfigurations())
//在spring事务正常提交时才缓存数据
.transactionAware()
.build();
}
private Map<String, RedisCacheConfiguration> getCacheConfigurations()