feat(cache): 新增 JetCache 自动配置

This commit is contained in:
2024-01-14 14:25:35 +08:00
parent e090083ba2
commit 156b02b3d7
6 changed files with 137 additions and 0 deletions

View File

@@ -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.");
}
}

View File

@@ -0,0 +1 @@
top.charles7c.continew.starter.cache.jetcache.autoconfigure.JetCacheAutoConfiguration

View File

@@ -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