From 8995d6f94ef2cf0e198c724dfd89b1085ebb43b3 Mon Sep 17 00:00:00 2001 From: Vincent Man Date: Wed, 31 Dec 2025 17:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=93=E5=AD=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LayeringCacheAutoConfiguration.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 a023bd8a..088f554a 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; -- Gitee