From ced71dafb6a41106fbb61166c00ed8046d55f4a7 Mon Sep 17 00:00:00 2001 From: Night_mare <55904958+chong-chonga@users.noreply.github.com> Date: Fri, 3 Dec 2021 16:14:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8replaceAll()=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9=E4=B8=BA=E8=B0=83=E7=94=A8=20replac?= =?UTF-8?q?e()=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 传给 replaceAll 的参数不是正则表达式, replaceAll 和 replace 效果是一样的, 且 replaceAll 由于会调用 ava.util.regex.Pattern.compile()方法, 导致性能消耗更大 --- .../src/main/java/me/zhengjie/aspect/LimitAspect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java index 908e022f..31f40404 100644 --- a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java +++ b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java @@ -68,7 +68,7 @@ public class LimitAspect { } } - ImmutableList keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replaceAll("/","_"))); + ImmutableList keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replace("/","_"))); String luaScript = buildLuaScript(); RedisScript redisScript = new DefaultRedisScript<>(luaScript, Number.class);