diff --git a/caf-boot-starters/caf-boot-starter-caching/src/main/java/io/iec/edp/caf/caching/config/LayeringCacheAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-caching/src/main/java/io/iec/edp/caf/caching/config/LayeringCacheAutoConfiguration.java index a023bd8ac82835afcda407ee0908dca4723f1900..088f554a3b3b80e95909f472d20525d0050dcf1c 100644 --- a/caf-boot-starters/caf-boot-starter-caching/src/main/java/io/iec/edp/caf/caching/config/LayeringCacheAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-caching/src/main/java/io/iec/edp/caf/caching/config/LayeringCacheAutoConfiguration.java @@ -25,6 +25,7 @@ import io.iec.edp.caf.caching.manager.LayeringCacheManager; import io.iec.edp.caf.caching.properties.LayeringCacheProperties; import io.iec.edp.caf.commons.caching.CacheFactory; import io.iec.edp.caf.commons.caching.JedisPoolManager; +import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.*; @@ -33,8 +34,6 @@ import org.springframework.context.annotation.*; * 多级缓存自动配置类 */ @Configuration(proxyBeanMethods = false) -//@ConditionalOnBean(RedisTemplate.class) -//@AutoConfigureAfter({RedisAutoConfiguration.class}) @EnableAspectJAutoProxy @EnableConfigurationProperties({ JedisPoolConfigProperties.class, @@ -46,25 +45,24 @@ import org.springframework.context.annotation.*; }) public class LayeringCacheAutoConfiguration { + @Value("${redis.enabled:true}") + private Boolean enableRedis; + /** - * @param properties - * @return + * 缓存管理 */ @Bean public CacheManager cafLayeringCacheManager(RedisCacheProperties redisCacheSettings, JedisPoolConfigProperties jedisPoolConfigProperties, LayeringCacheProperties properties) { - LayeringCacheManager layeringCacheManager = new LayeringCacheManager(redisCacheSettings, jedisPoolConfigProperties); + LayeringCacheManager layeringCacheManager = new LayeringCacheManager(redisCacheSettings, jedisPoolConfigProperties, enableRedis); // 默认开启统计功能 layeringCacheManager.setStats(properties.isStats()); return layeringCacheManager; } - /** - * @param properties - * @return - */ + @Deprecated @Bean - public io.iec.edp.caf.commons.layeringcache.manager.CacheManager cafOldLayeringCacheManager(io.iec.edp.caf.commons.layeringcache.properties.RedisCacheProperties redisCacheSettings, io.iec.edp.caf.commons.layeringcache.properties.JedisPoolConfigProperties jedisPoolConfigProperties,io.iec.edp.caf.commons.layeringcache.properties.LayeringCacheProperties properties) { - io.iec.edp.caf.commons.layeringcache.manager.LayeringCacheManager layeringCacheManager = new io.iec.edp.caf.commons.layeringcache.manager.LayeringCacheManager(redisCacheSettings, jedisPoolConfigProperties); + public io.iec.edp.caf.commons.layeringcache.manager.CacheManager cafOldLayeringCacheManager(RedisCacheProperties redisCacheSettings, JedisPoolConfigProperties jedisPoolConfigProperties, LayeringCacheProperties properties) { + io.iec.edp.caf.commons.layeringcache.manager.LayeringCacheManager layeringCacheManager = new io.iec.edp.caf.commons.layeringcache.manager.LayeringCacheManager(redisCacheSettings, jedisPoolConfigProperties, enableRedis); // 默认开启统计功能 layeringCacheManager.setStats(properties.isStats()); return layeringCacheManager;