fix:1.再次优化天气预报播放功能,把缓存数据存入磁盘,通过直接直接查找,性能不到70毫秒即返回2.添加定时清除缓存数据功能

This commit is contained in:
panbaolin 2026-08-07 11:52:11 +08:00
parent 68217c172a
commit 56afd228bb

View File

@ -0,0 +1,36 @@
package org.jeecg.job;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.FileUtils;
import org.jeecg.common.properties.SystemStorageProperties;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* 每周六凌晨2点清除天气预报缓存数据
*/
@Component
@RequiredArgsConstructor
public class CleanWeatherCacheData {
private final SystemStorageProperties systemStorageProperties;
@Scheduled(cron = "0 0 2 ? * SAT")
public void cleanCacheData(){
Path path = Paths.get(systemStorageProperties.getGribDataVariableCachePath());
if(Files.exists(path)){
try{
FileUtils.cleanDirectory(path.toFile());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}