feat(foundations):增加开通区域定时缓存的功能

This commit is contained in:
JIAN 2024-08-25 12:30:38 +08:00
parent 1db850a6cf
commit 9e78b3de0d
3 changed files with 47 additions and 11 deletions

View File

@ -63,23 +63,24 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.jzo2o</groupId>
<artifactId>jzo2o-redis</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.jzo2o</groupId>-->
<!-- <artifactId>jzo2o-canal-sync</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.jzo2o</groupId>
<artifactId>jzo2o-redis</artifactId>
</dependency>
<dependency>
<groupId>com.jzo2o</groupId>
<artifactId>jzo2o-mysql</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.jzo2o</groupId>-->
<!-- <artifactId>jzo2o-xxl-job</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.jzo2o</groupId>
<artifactId>jzo2o-xxl-job</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,35 @@
package com.jzo2o.foundations.handler;
import com.jzo2o.foundations.constants.RedisConstants;
import com.jzo2o.foundations.service.IRegionService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* xxl-job定时任务执行器
* @author JIAN
*/
@Slf4j
@Component
public class SpringCacheSyncHandler {
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Resource
private IRegionService regionService;
@XxlJob("activeRegionCacheSync")
public void activeRegionCacheSync() {
log.info(">>>>>>>>开始进行缓存同步,更新已启用区域");
// 清理缓存
String key = RedisConstants.CacheName.JZ_CACHE + "::ACTIVE_REGIONS";
redisTemplate.delete(key);
// 添加缓存
regionService.queryActiveRegionListCache();
log.info(">>>>>>>>开始进行缓存同步,更新已启用区域");
}
}

View File

@ -41,8 +41,8 @@ spring:
shared-configs: # 共享配置
- data-id: shared-redis-cluster.yaml # 共享redis配置
refresh: false
# - data-id: shared-xxl-job.yaml # xxl-job配置
# refresh: false
- data-id: shared-xxl-job.yaml # xxl-job配置
refresh: false
# - data-id: shared-rabbitmq.yaml # rabbitmq配置
# refresh: false
# - data-id: shared-es.yaml # rabbitmq配置
@ -73,4 +73,4 @@ logging:
com.jzo2o: debug
org.apache.http: info #es请求日志
feign:
enable: true
enable: true