From f2af0d93fd19a99b8ce45bd9d08d5f93ee6fdfae Mon Sep 17 00:00:00 2001 From: lilei Date: Fri, 10 Feb 2023 10:48:22 +0800 Subject: [PATCH 1/8] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/redis/config/RedisConfig.java | 25 ++++++++++++++++--- .../common/modules/redis/po/JeecgCache.java | 13 ++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/po/JeecgCache.java diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java index f72622b..18cb1c8 100644 --- a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java @@ -10,8 +10,11 @@ import org.jeecg.common.constant.CacheConstant; import org.jeecg.common.constant.GlobalConstants; +import org.jeecg.common.modules.redis.po.JeecgCache; import org.jeecg.common.modules.redis.receiver.RedisReceiver; import org.jeecg.common.modules.redis.writer.JeecgRedisCacheWriter; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; @@ -30,6 +33,8 @@ import javax.annotation.Resource; import java.time.Duration; +import java.util.HashMap; +import java.util.Map; import static java.util.Collections.singletonMap; @@ -45,6 +50,9 @@ public class RedisConfig extends CachingConfigurerSupport { @Resource private LettuceConnectionFactory lettuceConnectionFactory; + /**扩展缓存声明这个bean 就可以自动注入*/ + @Resource + private JeecgCache jeecgCache; /** * RedisTemplate配置 @@ -89,6 +97,17 @@ public CacheManager cacheManager(LettuceConnectionFactory factory) { // 以锁写入的方式创建RedisCacheWriter对象 //update-begin-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符* RedisCacheWriter writer = new JeecgRedisCacheWriter(factory, Duration.ofMillis(50L)); + Map customCache = new HashMap<>(); + if (jeecgCache == null) { + jeecgCache = new JeecgCache(); + } + jeecgCache.put(CacheConstant.TEST_DEMO_CACHE, 60*5); + jeecgCache.put(CacheConstant.PLUGIN_MALL_RANKING, 24*60*60); + jeecgCache.put(CacheConstant.PLUGIN_MALL_PAGE_LIST, 24*60*60); + + jeecgCache.getCache().forEach((k,v)->{ + customCache.put(k, redisCacheConfiguration.entryTtl(Duration.ZERO.withSeconds(v)).disableCachingNullValues()); + }); //RedisCacheWriter.lockingRedisCacheWriter(factory); // 创建默认缓存配置对象 /* 默认配置,设置缓存有效期 1小时*/ @@ -97,10 +116,8 @@ public CacheManager cacheManager(LettuceConnectionFactory factory) { RedisCacheManager cacheManager = RedisCacheManager.builder(writer).cacheDefaults(redisCacheConfiguration) .withInitialCacheConfigurations(singletonMap(CacheConstant.SYS_DICT_TABLE_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(10)).disableCachingNullValues() - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer)))) - .withInitialCacheConfigurations(singletonMap(CacheConstant.TEST_DEMO_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(5)).disableCachingNullValues())) - .withInitialCacheConfigurations(singletonMap(CacheConstant.PLUGIN_MALL_RANKING, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(24)).disableCachingNullValues())) - .withInitialCacheConfigurations(singletonMap(CacheConstant.PLUGIN_MALL_PAGE_LIST, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(24)).disableCachingNullValues())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer)))) + .withInitialCacheConfigurations(customCache) .transactionAware().build(); //update-end-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符* return cacheManager; diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/po/JeecgCache.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/po/JeecgCache.java new file mode 100644 index 0000000..6c538c7 --- /dev/null +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/po/JeecgCache.java @@ -0,0 +1,13 @@ +package org.jeecg.common.modules.redis.po; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; +@Data +public class JeecgCache { + private Map cache= new HashMap<>(); + public void put(String key,Integer expire){ + cache.put(key,expire); + } +} From 8388c6e0b87afde1f517623f51cf652f7ae09ae8 Mon Sep 17 00:00:00 2001 From: lilei Date: Fri, 10 Feb 2023 11:24:42 +0800 Subject: [PATCH 2/8] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/modules/redis/config/RedisConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java index 18cb1c8..c3050ff 100644 --- a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java @@ -106,6 +106,7 @@ public CacheManager cacheManager(LettuceConnectionFactory factory) { jeecgCache.put(CacheConstant.PLUGIN_MALL_PAGE_LIST, 24*60*60); jeecgCache.getCache().forEach((k,v)->{ + log.info("自定义缓存配置,key:{},value:{}",k,v); customCache.put(k, redisCacheConfiguration.entryTtl(Duration.ZERO.withSeconds(v)).disableCachingNullValues()); }); //RedisCacheWriter.lockingRedisCacheWriter(factory); From 607aa94cfd9ab51c9be4cadb7a97070d711fbe21 Mon Sep 17 00:00:00 2001 From: zhong Date: Mon, 6 Mar 2023 12:49:53 +0800 Subject: [PATCH 3/8] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- jeecg-boot-common/pom.xml | 2 +- jeecg-boot-starter-cloud/pom.xml | 2 +- jeecg-boot-starter-job/pom.xml | 2 +- jeecg-boot-starter-lock/pom.xml | 2 +- jeecg-boot-starter-mongon/pom.xml | 2 +- jeecg-boot-starter-rabbitmq/pom.xml | 2 +- jeecg-boot-starter-seata/pom.xml | 2 +- jeecg-boot-starter-shardingsphere/pom.xml | 2 +- pom.xml | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b690d07..5697e72 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # jeecg-boot-starter -当前最新版本: 3.4.4(发布日期:20221121) +当前最新版本: 3.5.0(发布日期:20221121) ### 介绍 > jeecg-boot的starter启动模块独立出来,简化项目,便于维护。 diff --git a/jeecg-boot-common/pom.xml b/jeecg-boot-common/pom.xml index 28c3713..86e8e95 100644 --- a/jeecg-boot-common/pom.xml +++ b/jeecg-boot-common/pom.xml @@ -4,7 +4,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 公共模块 diff --git a/jeecg-boot-starter-cloud/pom.xml b/jeecg-boot-starter-cloud/pom.xml index 5418cb6..7b825e9 100644 --- a/jeecg-boot-starter-cloud/pom.xml +++ b/jeecg-boot-starter-cloud/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-cloud diff --git a/jeecg-boot-starter-job/pom.xml b/jeecg-boot-starter-job/pom.xml index a14cdf4..6f5e69b 100644 --- a/jeecg-boot-starter-job/pom.xml +++ b/jeecg-boot-starter-job/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-job diff --git a/jeecg-boot-starter-lock/pom.xml b/jeecg-boot-starter-lock/pom.xml index bb27418..962b743 100644 --- a/jeecg-boot-starter-lock/pom.xml +++ b/jeecg-boot-starter-lock/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-lock diff --git a/jeecg-boot-starter-mongon/pom.xml b/jeecg-boot-starter-mongon/pom.xml index 12e53d0..100bd15 100644 --- a/jeecg-boot-starter-mongon/pom.xml +++ b/jeecg-boot-starter-mongon/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-mongon diff --git a/jeecg-boot-starter-rabbitmq/pom.xml b/jeecg-boot-starter-rabbitmq/pom.xml index d39f6d7..72f6262 100644 --- a/jeecg-boot-starter-rabbitmq/pom.xml +++ b/jeecg-boot-starter-rabbitmq/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-rabbitmq diff --git a/jeecg-boot-starter-seata/pom.xml b/jeecg-boot-starter-seata/pom.xml index 68238d9..cd74157 100644 --- a/jeecg-boot-starter-seata/pom.xml +++ b/jeecg-boot-starter-seata/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-seata diff --git a/jeecg-boot-starter-shardingsphere/pom.xml b/jeecg-boot-starter-shardingsphere/pom.xml index 14e36c0..e852048 100644 --- a/jeecg-boot-starter-shardingsphere/pom.xml +++ b/jeecg-boot-starter-shardingsphere/pom.xml @@ -5,7 +5,7 @@ jeecg-boot-starter org.jeecgframework.boot - 3.4.4 + 3.5.0 4.0.0 jeecg-boot-starter-shardingsphere diff --git a/pom.xml b/pom.xml index 170dc0f..e7a5460 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ jeecg-boot-starter pom JEECG BOOT STARTER ${project.version} - 3.4.4 + 3.5.0 ${project.version} @@ -38,7 +38,7 @@ jeecg-boot-starter-job jeecg-boot-starter-lock jeecg-boot-starter-rabbitmq - jeecg-boot-starter-shardingsphere + jeecg-boot-starter-mongon From 290ef314dfcf276373efe73c6c3db430be141a90 Mon Sep 17 00:00:00 2001 From: zhong Date: Thu, 9 Mar 2023 14:40:39 +0800 Subject: [PATCH 4/8] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5697e72..252770b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # jeecg-boot-starter -当前最新版本: 3.5.0(发布日期:20221121) +当前最新版本: 3.5.0(发布日期:20230308) ### 介绍 > jeecg-boot的starter启动模块独立出来,简化项目,便于维护。 From a6be2adf1eb636dd0f9933222c8701f769808a18 Mon Sep 17 00:00:00 2001 From: zhong Date: Fri, 10 Mar 2023 14:54:18 +0800 Subject: [PATCH 5/8] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/modules/redis/config/RedisConfig.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java index c3050ff..8fe4c39 100644 --- a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java @@ -13,6 +13,7 @@ import org.jeecg.common.modules.redis.po.JeecgCache; import org.jeecg.common.modules.redis.receiver.RedisReceiver; import org.jeecg.common.modules.redis.writer.JeecgRedisCacheWriter; +import org.jeecg.common.util.SpringContextHolder; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.CacheManager; @@ -20,6 +21,7 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.cache.RedisCacheWriter; @@ -50,9 +52,6 @@ public class RedisConfig extends CachingConfigurerSupport { @Resource private LettuceConnectionFactory lettuceConnectionFactory; - /**扩展缓存声明这个bean 就可以自动注入*/ - @Resource - private JeecgCache jeecgCache; /** * RedisTemplate配置 @@ -98,6 +97,8 @@ public CacheManager cacheManager(LettuceConnectionFactory factory) { //update-begin-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符* RedisCacheWriter writer = new JeecgRedisCacheWriter(factory, Duration.ofMillis(50L)); Map customCache = new HashMap<>(); + /*隐式加载*/ + JeecgCache jeecgCache = SpringContextHolder.getBean(JeecgCache.class); if (jeecgCache == null) { jeecgCache = new JeecgCache(); } From 8839c59098811a64b538e353f24586b7602d1fbf Mon Sep 17 00:00:00 2001 From: zhong Date: Fri, 10 Mar 2023 15:03:33 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/modules/redis/config/RedisConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java index 8fe4c39..676443e 100644 --- a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java @@ -13,7 +13,6 @@ import org.jeecg.common.modules.redis.po.JeecgCache; import org.jeecg.common.modules.redis.receiver.RedisReceiver; import org.jeecg.common.modules.redis.writer.JeecgRedisCacheWriter; -import org.jeecg.common.util.SpringContextHolder; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.CacheManager; @@ -52,6 +51,9 @@ public class RedisConfig extends CachingConfigurerSupport { @Resource private LettuceConnectionFactory lettuceConnectionFactory; + /**扩展缓存声明这个bean 就可以自动注入*/ + @Resource + private JeecgCache jeecgCache; /** * RedisTemplate配置 @@ -97,8 +99,6 @@ public CacheManager cacheManager(LettuceConnectionFactory factory) { //update-begin-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符* RedisCacheWriter writer = new JeecgRedisCacheWriter(factory, Duration.ofMillis(50L)); Map customCache = new HashMap<>(); - /*隐式加载*/ - JeecgCache jeecgCache = SpringContextHolder.getBean(JeecgCache.class); if (jeecgCache == null) { jeecgCache = new JeecgCache(); } From ea9bd465570988c6fe4cea814eaea31a716be442 Mon Sep 17 00:00:00 2001 From: zhong Date: Thu, 16 Mar 2023 09:59:34 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/modules/redis/config/RedisConfig.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java index 676443e..e594bce 100644 --- a/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java +++ b/jeecg-boot-common/src/main/java/org/jeecg/common/modules/redis/config/RedisConfig.java @@ -13,12 +13,18 @@ import org.jeecg.common.modules.redis.po.JeecgCache; import org.jeecg.common.modules.redis.receiver.RedisReceiver; import org.jeecg.common.modules.redis.writer.JeecgRedisCacheWriter; +import org.jeecg.common.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.cache.RedisCacheConfiguration; @@ -52,9 +58,10 @@ public class RedisConfig extends CachingConfigurerSupport { @Resource private LettuceConnectionFactory lettuceConnectionFactory; /**扩展缓存声明这个bean 就可以自动注入*/ - @Resource + @Autowired(required = false) private JeecgCache jeecgCache; + /** * RedisTemplate配置 * @param lettuceConnectionFactory @@ -87,6 +94,7 @@ public RedisTemplate redisTemplate(LettuceConnectionFactory lett * @return */ @Bean + public CacheManager cacheManager(LettuceConnectionFactory factory) { Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = jacksonSerializer(); // 配置序列化(解决乱码的问题),并且配置缓存默认有效期 6小时 From edeb628fe765cc04697e0c36b173e863ecb62fa6 Mon Sep 17 00:00:00 2001 From: zhong Date: Tue, 18 Apr 2023 13:32:40 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ca408d8..c2f4901 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ jeecg-boot-starter-job jeecg-boot-starter-lock jeecg-boot-starter-rabbitmq - jeecg-boot-starter-shardingsphere + jeecg-boot-starter-mongon