From 8fdf462c6cdf4e2b034a3c96112232bfcce3adb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=B2=BE=E5=8D=8E?= <842761733@qq.com> Date: Thu, 24 Oct 2019 19:22:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD=E7=82=B9=EF=BC=9A?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=B8=85=E7=90=86=E6=97=B6=E9=97=B4cron?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=20link=20#I1147X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jodconverter-web/src/main/config/application.properties | 5 +++-- .../src/main/java/cn/keking/utils/ShedulerClean.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jodconverter-web/src/main/config/application.properties b/jodconverter-web/src/main/config/application.properties index e850aeb0..f9b9a50b 100644 --- a/jodconverter-web/src/main/config/application.properties +++ b/jodconverter-web/src/main/config/application.properties @@ -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等反向代理,需要手动设置 diff --git a/jodconverter-web/src/main/java/cn/keking/utils/ShedulerClean.java b/jodconverter-web/src/main/java/cn/keking/utils/ShedulerClean.java index b69b6a61..495f4353 100644 --- a/jodconverter-web/src/main/java/cn/keking/utils/ShedulerClean.java +++ b/jodconverter-web/src/main/java/cn/keking/utils/ShedulerClean.java @@ -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();