mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-11-04 22:57:15 +08:00 
			
		
		
		
	feat(cache): 新增 JetCache 自动配置
This commit is contained in:
		@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0"
 | 
				
			||||||
 | 
					         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>top.charles7c.continew</groupId>
 | 
				
			||||||
 | 
					        <artifactId>continew-starter-cache</artifactId>
 | 
				
			||||||
 | 
					        <version>${revision}</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <artifactId>continew-starter-cache-jetcache</artifactId>
 | 
				
			||||||
 | 
					    <packaging>jar</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <name>${project.artifactId}</name>
 | 
				
			||||||
 | 
					    <description>ContiNew Starter 缓存模块 - JetCache</description>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <!-- JetCache(一个基于 Java 的缓存系统封装,提供统一的 API 和注解来简化缓存的使用。提供了比 SpringCache 更加强大的注解,可以原生的支持 TTL、两级缓存、分布式自动刷新,还提供了 Cache 接口用于手工缓存操作) -->
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jetcache-autoconfigure</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- JetCache 注解 -->
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jetcache-anno</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- JetCache Redisson 适配 -->
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jetcache-redisson</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.apache.commons</groupId>
 | 
				
			||||||
 | 
					            <artifactId>commons-pool2</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- 缓存模块 - Redisson -->
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>top.charles7c.continew</groupId>
 | 
				
			||||||
 | 
					            <artifactId>continew-starter-cache-redisson</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
 | 
				
			||||||
 | 
					 * <p>
 | 
				
			||||||
 | 
					 * 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
 | 
				
			||||||
 | 
					 * <p>
 | 
				
			||||||
 | 
					 * http://www.gnu.org/licenses/lgpl.html
 | 
				
			||||||
 | 
					 * <p>
 | 
				
			||||||
 | 
					 * 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.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					top.charles7c.continew.starter.cache.jetcache.autoconfigure.JetCacheAutoConfiguration
 | 
				
			||||||
@@ -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
 | 
				
			||||||
@@ -18,6 +18,7 @@
 | 
				
			|||||||
    <modules>
 | 
					    <modules>
 | 
				
			||||||
        <module>continew-starter-cache-redisson</module>
 | 
					        <module>continew-starter-cache-redisson</module>
 | 
				
			||||||
        <module>continew-starter-cache-springcache</module>
 | 
					        <module>continew-starter-cache-springcache</module>
 | 
				
			||||||
 | 
					        <module>continew-starter-cache-jetcache</module>
 | 
				
			||||||
    </modules>
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <dependencies>
 | 
					    <dependencies>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,7 @@
 | 
				
			|||||||
        <mybatis-plus.version>3.5.5</mybatis-plus.version>
 | 
					        <mybatis-plus.version>3.5.5</mybatis-plus.version>
 | 
				
			||||||
        <dynamic-datasource.version>4.2.0</dynamic-datasource.version>
 | 
					        <dynamic-datasource.version>4.2.0</dynamic-datasource.version>
 | 
				
			||||||
        <p6spy.version>3.9.1</p6spy.version>
 | 
					        <p6spy.version>3.9.1</p6spy.version>
 | 
				
			||||||
 | 
					        <jetcache.version>2.7.4</jetcache.version>
 | 
				
			||||||
        <redisson.version>3.25.2</redisson.version>
 | 
					        <redisson.version>3.25.2</redisson.version>
 | 
				
			||||||
        <sms4j.version>3.0.4</sms4j.version>
 | 
					        <sms4j.version>3.0.4</sms4j.version>
 | 
				
			||||||
        <aj-captcha.version>1.3.0</aj-captcha.version>
 | 
					        <aj-captcha.version>1.3.0</aj-captcha.version>
 | 
				
			||||||
@@ -140,6 +141,33 @@
 | 
				
			|||||||
                <version>${p6spy.version}</version>
 | 
					                <version>${p6spy.version}</version>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <!-- JetCache(一个基于 Java 的缓存系统封装,提供统一的 API 和注解来简化缓存的使用。提供了比 SpringCache 更加强大的注解,可以原生的支持 TTL、两级缓存、分布式自动刷新,还提供了 Cache 接口用于手工缓存操作) -->
 | 
				
			||||||
 | 
					            <dependency>
 | 
				
			||||||
 | 
					                <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					                <artifactId>jetcache-autoconfigure</artifactId>
 | 
				
			||||||
 | 
					                <version>${jetcache.version}</version>
 | 
				
			||||||
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <!-- JetCache 注解 -->
 | 
				
			||||||
 | 
					            <dependency>
 | 
				
			||||||
 | 
					                <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					                <artifactId>jetcache-anno</artifactId>
 | 
				
			||||||
 | 
					                <version>${jetcache.version}</version>
 | 
				
			||||||
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <!-- JetCache Redisson 适配 -->
 | 
				
			||||||
 | 
					            <dependency>
 | 
				
			||||||
 | 
					                <groupId>com.alicp.jetcache</groupId>
 | 
				
			||||||
 | 
					                <artifactId>jetcache-redisson</artifactId>
 | 
				
			||||||
 | 
					                <version>${jetcache.version}</version>
 | 
				
			||||||
 | 
					                <exclusions>
 | 
				
			||||||
 | 
					                    <exclusion>
 | 
				
			||||||
 | 
					                        <groupId>org.redisson</groupId>
 | 
				
			||||||
 | 
					                        <artifactId>redisson</artifactId>
 | 
				
			||||||
 | 
					                    </exclusion>
 | 
				
			||||||
 | 
					                </exclusions>
 | 
				
			||||||
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <!-- Redisson(不仅仅是一个 Redis Java 客户端) -->
 | 
					            <!-- Redisson(不仅仅是一个 Redis Java 客户端) -->
 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>org.redisson</groupId>
 | 
					                <groupId>org.redisson</groupId>
 | 
				
			||||||
@@ -262,6 +290,13 @@
 | 
				
			|||||||
                <version>${revision}</version>
 | 
					                <version>${revision}</version>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <!-- 缓存模块 - JetCache -->
 | 
				
			||||||
 | 
					            <dependency>
 | 
				
			||||||
 | 
					                <groupId>top.charles7c.continew</groupId>
 | 
				
			||||||
 | 
					                <artifactId>continew-starter-cache-jetcache</artifactId>
 | 
				
			||||||
 | 
					                <version>${revision}</version>
 | 
				
			||||||
 | 
					            </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <!-- 缓存模块 - Spring Cache -->
 | 
					            <!-- 缓存模块 - Spring Cache -->
 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>top.charles7c.continew</groupId>
 | 
					                <groupId>top.charles7c.continew</groupId>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user