feat: 增加每半天定时清空缓存

dev
huangfeng 1 day ago
parent 638f97317a
commit 3862bfc2ca

@ -16,6 +16,7 @@ import com.shxy.xymanager_common.vo.TerminalPhotoSelectVo;
import com.shxy.xymanager_common.vo.TerminalSelectVo; import com.shxy.xymanager_common.vo.TerminalSelectVo;
import com.shxy.xymanager_dao.dao.TerminalPositionsMapper; import com.shxy.xymanager_dao.dao.TerminalPositionsMapper;
import com.shxy.xymanager_dao.dao.TerminalStatusDao; import com.shxy.xymanager_dao.dao.TerminalStatusDao;
import com.shxy.xymanager_framework.timeTask.ClearCacheTask;
import com.shxy.xymanager_service.service.*; import com.shxy.xymanager_service.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -60,7 +61,15 @@ public class TerminalExtController extends BaseController {
TerminalSimcardService simcardService; TerminalSimcardService simcardService;
@Resource @Resource
CameraScheduleService cameraScheduleService; CameraScheduleService cameraScheduleService;
@Resource
ClearCacheTask clearCacheTask;
@GetMapping("clearCache")
@ApiOperation("清空缓存")
public ResponseReult<String> clearCache() {
clearCacheTask.clearAllCache();
return ResponseReult.success("OK");
}
@PostMapping("batchUpdate") @PostMapping("batchUpdate")
@ApiOperation("批量修改装置") @ApiOperation("批量修改装置")

@ -2,6 +2,8 @@ package com.shxy.xymanager_framework.timeTask;
import com.shxy.xymanager_common.zhiping.PulliceModel; import com.shxy.xymanager_common.zhiping.PulliceModel;
import com.shxy.xymanager_service.service.NewCacheService; import com.shxy.xymanager_service.service.NewCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -9,6 +11,7 @@ import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
@Service @Service
@Slf4j
public class ClearCacheTask { public class ClearCacheTask {
public static HashMap<Integer, Long> reportCountMap = new HashMap<>(); public static HashMap<Integer, Long> reportCountMap = new HashMap<>();
@ -37,4 +40,9 @@ public class ClearCacheTask {
lowVoltMap.clear(); lowVoltMap.clear();
} }
@Scheduled(cron = "0 2 0,12 * * ?")
@CacheEvict(cacheNames = {"permissionfull", "permissionover", "fulltree", "cacheTerminalMap", "termAndchannelMap", "cacheTower"}, allEntries = true)
public void clearAllCache() {
log.info("清空全部缓存.");
}
} }

Loading…
Cancel
Save