Просмотр исходного кода

aipt,data的缓存都放入原先icss的缓存片区(5)
在aipt和icssman加入清理所有缓存接口

gaodm 5 лет назад
Родитель
Сommit
ab0a8bd407

+ 2 - 0
aipt-service/src/main/java/com/diagbot/web/CacheController.java

@@ -5,6 +5,7 @@ import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.CacheFacade;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @SuppressWarnings("unchecked")
 @Api(value = "知识库预处理缓存API", tags = { "知识库预处理缓存API" })
+@Slf4j
 public class CacheController {
 
 

+ 1 - 1
config-server/src/main/resources/shared/aipt-service-dev.yml

@@ -69,7 +69,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 9 # aipt服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/aipt-service-local.yml

@@ -69,7 +69,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 9 # aipt服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6378 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/aipt-service-pre.yml

@@ -69,7 +69,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 9 # aipt服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.121  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/aipt-service-pro.yml

@@ -69,7 +69,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 9 # aipt服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.122  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/aipt-service-test.yml

@@ -69,7 +69,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 9 # aipt服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.241  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/data-service-dev.yml

@@ -24,7 +24,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 8 # data服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/data-service-local.yml

@@ -24,7 +24,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 8 # data服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.236  #Redis服务器地址
     port: 6378 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/data-service-pre.yml

@@ -24,7 +24,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 8 # data服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.121  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/data-service-pro.yml

@@ -24,7 +24,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 8 # data服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.122  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 1
config-server/src/main/resources/shared/data-service-test.yml

@@ -23,7 +23,7 @@ spring:
   #redis
   redis:
     database:
-      data-service: 8 # data服务缓存信息
+      data-service: 5 # Redis缓存索引
     host: 192.168.2.241  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)

+ 1 - 0
icssman-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -34,6 +34,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/getIcssEnumsData").permitAll()
                 .antMatchers("/questionInfo/indexByLexicon").permitAll()
                 .antMatchers("/cache/clearCache").permitAll()
+                .antMatchers("/cache/allClear").permitAll()
                 .antMatchers("/questionInfo/indexForkl").permitAll()
                 .antMatchers("/**").authenticated();
 //                        .antMatchers("/**").permitAll();

+ 1 - 0
icssman-service/src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -95,6 +95,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/dictionaryInfo/getList", request)
                 || matchers("/questionInfo/indexByLexicon", request)
                 || matchers("/cache/clearCache", request)
+                || matchers("/cache/allClear", request)
                 || matchers("/questionInfo/indexForkl", request)
                 || matchers("/", request)) {
             return true;

+ 18 - 2
icssman-service/src/main/java/com/diagbot/web/CacheController.java

@@ -5,10 +5,12 @@ import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.CacheFacade;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.IdListVO;
-import com.diagbot.vo.IdVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Caching;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -27,7 +29,7 @@ import java.util.List;
 @RequestMapping("/cache")
 @SuppressWarnings("unchecked")
 @Api(value = "缓存相关API", tags = { "缓存相关API" })
-@ApiIgnore
+@Slf4j
 public class CacheController {
     @Autowired
     CacheFacade cacheFacade;
@@ -37,6 +39,7 @@ public class CacheController {
     @PostMapping("/clearCache")
     @SysLogger("clearCache")
     @Transactional
+    @ApiIgnore
     public RespDTO<Boolean> clearCache(@RequestBody IdListVO idListVO) {
         List<Long> ids = idListVO.getIdList();
         if (ListUtil.isNotEmpty(ids)) {
@@ -46,4 +49,17 @@ public class CacheController {
         }
         return RespDTO.onSuc(true);
     }
+
+    @ApiOperation(value = "清除所有缓存[by:gaodm]",
+            notes = "")
+    @PostMapping("/allClear")
+    @SysLogger("allClear")
+    @Caching(evict = { @CacheEvict(value = "icss-service", allEntries = true),
+            @CacheEvict(value = "data-service", allEntries = true),
+            @CacheEvict(value = "aipt-service", allEntries = true),
+            @CacheEvict(value = "tagCache", allEntries = true) })
+    public RespDTO<Boolean> allClear() {
+        log.info("清理了icss,data,aipt的所有缓存!");
+        return RespDTO.onSuc(true);
+    }
 }