Преглед изворни кода

:zap: 优化缓存清空逻辑

smallchill пре 5 година
родитељ
комит
a1dec4a486

+ 12 - 10
src/main/java/org/springblade/modules/auth/endpoint/BladeTokenEndPoint.java

@@ -23,7 +23,6 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 import org.springblade.common.cache.CacheNames;
-import org.springblade.core.cache.constant.CacheConstant;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.jwt.JwtUtil;
 import org.springblade.core.jwt.props.JwtProperties;
@@ -48,6 +47,8 @@ import javax.servlet.http.HttpServletResponse;
 import java.time.Duration;
 import java.util.UUID;
 
+import static org.springblade.core.cache.constant.CacheConstant.*;
+
 /**
  * 令牌端点
  *
@@ -122,15 +123,16 @@ public class BladeTokenEndPoint {
 	@GetMapping("/oauth/clear-cache")
 	@ApiOperation(value = "清除缓存")
 	public Kv clearCache() {
-		CacheUtil.clear(CacheConstant.BIZ_CACHE);
-		CacheUtil.clear(CacheConstant.USER_CACHE);
-		CacheUtil.clear(CacheConstant.DICT_CACHE);
-		CacheUtil.clear(CacheConstant.FLOW_CACHE);
-		CacheUtil.clear(CacheConstant.SYS_CACHE);
-		CacheUtil.clear(CacheConstant.PARAM_CACHE);
-		CacheUtil.clear(CacheConstant.RESOURCE_CACHE);
-		CacheUtil.clear(CacheConstant.MENU_CACHE);
-		CacheUtil.clear(CacheConstant.MENU_CACHE, Boolean.FALSE);
+		CacheUtil.clear(BIZ_CACHE);
+		CacheUtil.clear(USER_CACHE);
+		CacheUtil.clear(DICT_CACHE);
+		CacheUtil.clear(FLOW_CACHE);
+		CacheUtil.clear(SYS_CACHE);
+		CacheUtil.clear(PARAM_CACHE);
+		CacheUtil.clear(RESOURCE_CACHE);
+		CacheUtil.clear(MENU_CACHE);
+		CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
+		CacheUtil.clear(PARAM_CACHE, Boolean.FALSE);
 		return Kv.create().set("success", "true").set("msg", "success");
 	}
 }

+ 2 - 0
src/main/java/org/springblade/modules/system/controller/ParamController.java

@@ -87,6 +87,7 @@ public class ParamController extends BladeController {
 	@ApiOperation(value = "新增或修改", notes = "传入param")
 	public R submit(@Valid @RequestBody Param param) {
 		CacheUtil.clear(PARAM_CACHE);
+		CacheUtil.clear(PARAM_CACHE, Boolean.FALSE);
 		return R.status(paramService.saveOrUpdate(param));
 	}
 
@@ -99,6 +100,7 @@ public class ParamController extends BladeController {
 	@ApiOperation(value = "逻辑删除", notes = "传入ids")
 	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
 		CacheUtil.clear(PARAM_CACHE);
+		CacheUtil.clear(PARAM_CACHE, Boolean.FALSE);
 		return R.status(paramService.deleteLogic(Func.toLongList(ids)));
 	}