Commit fc8e4662bb6998df397950e6b7318e164b8d23f9
1 parent
75167383
【功能优化】限流的配置,增加 expire 过期,原因参见 https://t.zsxq.com/lcR0W 场景
Showing
1 changed file
with
2 additions
and
0 deletions
yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/redis/RateLimiterRedisDAO.java
| ... | ... | @@ -44,6 +44,7 @@ public class RateLimiterRedisDAO { |
| 44 | 44 | RateLimiterConfig config = rateLimiter.getConfig(); |
| 45 | 45 | if (config == null) { |
| 46 | 46 | rateLimiter.trySetRate(RateType.OVERALL, count, rateInterval, RateIntervalUnit.SECONDS); |
| 47 | + rateLimiter.expire(rateInterval, TimeUnit.SECONDS); // 原因参见 https://t.zsxq.com/lcR0W | |
| 47 | 48 | return rateLimiter; |
| 48 | 49 | } |
| 49 | 50 | // 2. 如果存在,并且配置相同,则直接返回 |
| ... | ... | @@ -54,6 +55,7 @@ public class RateLimiterRedisDAO { |
| 54 | 55 | } |
| 55 | 56 | // 3. 如果存在,并且配置不同,则进行新建 |
| 56 | 57 | rateLimiter.setRate(RateType.OVERALL, count, rateInterval, RateIntervalUnit.SECONDS); |
| 58 | + rateLimiter.expire(rateInterval, TimeUnit.SECONDS); // 原因参见 https://t.zsxq.com/lcR0W | |
| 57 | 59 | return rateLimiter; |
| 58 | 60 | } |
| 59 | 61 | ... | ... |