新功能点:缓存清理时间cron表达式支持自定义 link #I1147X

pull/12/head
陈精华 2019-10-24 19:22:23 +08:00 committed by kl
parent f7c7411bcf
commit 8fdf462c6c
2 changed files with 6 additions and 4 deletions

View File

@ -27,8 +27,9 @@ spring.http.multipart.max-file-size=100MB
#redis连接
#spring.redisson.address = 192.168.1.204:6379
#spring.redisson.password = xxx
#缓存自动清理(每晚3点自动清理) true 为开启,注释掉或其他值都为关闭
cache.clean = true
cache.clean.enabled = true
#缓存自动清理时间cache.clean.enabled = true时才有用cron表达式基于Quartz cron
cache.clean.cron = 0 0 3 * * ?
#######################################可在运行时动态配置#######################################
#提供预览服务的地址默认从请求url读如果使用nginx等反向代理需要手动设置

View File

@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
* @since: 2019/6/11 7:45
*/
@Component
@ConditionalOnExpression("'${cache.clean:false}'.equals('true')")
@ConditionalOnExpression("'${cache.clean.enabled:false}'.equals('true')")
public class ShedulerClean {
private static final Logger LOGGER = LoggerFactory.getLogger(ShedulerClean.class);
@ -24,7 +24,8 @@ public class ShedulerClean {
private String fileDir = ConfigConstants.getFileDir();
@Scheduled(cron = "0 0 3 * * ?") //每晚3点执行一次
//默认每晚3点执行一次
@Scheduled(cron = "${cache.clean.cron:0 0 3 * * ?}")
public void clean() {
LOGGER.info("Cache clean start");
cacheService.cleanCache();