From 156b02b3d77fa9f0476c23182d35df030a3ea66a Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 14 Jan 2024 14:25:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(cache):=20=E6=96=B0=E5=A2=9E=20JetCache=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../continew-starter-cache-jetcache/pom.xml | 48 +++++++++++++++++++ .../JetCacheAutoConfiguration.java | 44 +++++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../main/resources/default-cache-jetcache.yml | 8 ++++ continew-starter-cache/pom.xml | 1 + continew-starter-dependencies/pom.xml | 35 ++++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 continew-starter-cache/continew-starter-cache-jetcache/pom.xml create mode 100644 continew-starter-cache/continew-starter-cache-jetcache/src/main/java/top/charles7c/continew/starter/cache/jetcache/autoconfigure/JetCacheAutoConfiguration.java create mode 100644 continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/default-cache-jetcache.yml diff --git a/continew-starter-cache/continew-starter-cache-jetcache/pom.xml b/continew-starter-cache/continew-starter-cache-jetcache/pom.xml new file mode 100644 index 00000000..b859faa5 --- /dev/null +++ b/continew-starter-cache/continew-starter-cache-jetcache/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + top.charles7c.continew + continew-starter-cache + ${revision} + + + continew-starter-cache-jetcache + jar + + ${project.artifactId} + ContiNew Starter 缓存模块 - JetCache + + + + + com.alicp.jetcache + jetcache-autoconfigure + + + + + com.alicp.jetcache + jetcache-anno + + + + + com.alicp.jetcache + jetcache-redisson + + + + org.apache.commons + commons-pool2 + + + + + top.charles7c.continew + continew-starter-cache-redisson + + + \ No newline at end of file diff --git a/continew-starter-cache/continew-starter-cache-jetcache/src/main/java/top/charles7c/continew/starter/cache/jetcache/autoconfigure/JetCacheAutoConfiguration.java b/continew-starter-cache/continew-starter-cache-jetcache/src/main/java/top/charles7c/continew/starter/cache/jetcache/autoconfigure/JetCacheAutoConfiguration.java new file mode 100644 index 00000000..cc8a4cf1 --- /dev/null +++ b/continew-starter-cache/continew-starter-cache-jetcache/src/main/java/top/charles7c/continew/starter/cache/jetcache/autoconfigure/JetCacheAutoConfiguration.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package top.charles7c.continew.starter.cache.jetcache.autoconfigure; + +import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; +import top.charles7c.continew.starter.core.handler.GeneralPropertySourceFactory; + +/** + * JetCache 自动配置 + * + * @author Charles7c + * @since 1.2.0 + */ +@Slf4j +@AutoConfiguration +@RequiredArgsConstructor +@Import(com.alicp.jetcache.autoconfigure.JetCacheAutoConfiguration.class) +@PropertySource(value = "classpath:default-cache-jetcache.yml", factory = GeneralPropertySourceFactory.class) +public class JetCacheAutoConfiguration { + + @PostConstruct + public void postConstruct() { + log.debug("[ContiNew Starter] - Auto Configuration 'JetCache' completed initialization."); + } +} diff --git a/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..7cb5d93b --- /dev/null +++ b/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +top.charles7c.continew.starter.cache.jetcache.autoconfigure.JetCacheAutoConfiguration \ No newline at end of file diff --git a/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/default-cache-jetcache.yml b/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/default-cache-jetcache.yml new file mode 100644 index 00000000..d4615fc9 --- /dev/null +++ b/continew-starter-cache/continew-starter-cache-jetcache/src/main/resources/default-cache-jetcache.yml @@ -0,0 +1,8 @@ +--- ### JetCache 配置(https://github.com/alibaba/jetcache/blob/master/docs/CN/Config.md) +jetcache: + # 统计间隔(默认 0,表示不统计) + statIntervalMinutes: 15 + # jetcache-anno 把 cacheName 作为远程缓存key前缀, + # 2.4.3 以前的版本总是把 areaName 加在 cacheName 中,因此 areaName 也出现在 key 前缀中, + # 2.4.4 以后可以配置,为了保持远程 key 兼容默认值为 true,但是新项目的话 false 更合理些,2.7 默认值已改为 false。 + areaInCacheName: false \ No newline at end of file diff --git a/continew-starter-cache/pom.xml b/continew-starter-cache/pom.xml index cf0103e8..a823895f 100644 --- a/continew-starter-cache/pom.xml +++ b/continew-starter-cache/pom.xml @@ -18,6 +18,7 @@ continew-starter-cache-redisson continew-starter-cache-springcache + continew-starter-cache-jetcache diff --git a/continew-starter-dependencies/pom.xml b/continew-starter-dependencies/pom.xml index 49f815cf..a4053b5d 100644 --- a/continew-starter-dependencies/pom.xml +++ b/continew-starter-dependencies/pom.xml @@ -60,6 +60,7 @@ 3.5.5 4.2.0 3.9.1 + 2.7.4 3.25.2 3.0.4 1.3.0 @@ -140,6 +141,33 @@ ${p6spy.version} + + + com.alicp.jetcache + jetcache-autoconfigure + ${jetcache.version} + + + + + com.alicp.jetcache + jetcache-anno + ${jetcache.version} + + + + + com.alicp.jetcache + jetcache-redisson + ${jetcache.version} + + + org.redisson + redisson + + + + org.redisson @@ -262,6 +290,13 @@ ${revision} + + + top.charles7c.continew + continew-starter-cache-jetcache + ${revision} + + top.charles7c.continew