refactor(rate-limit): 完善双层滑动窗口限流实现

This commit is contained in:
Ray.Hao
2026-07-17 00:19:12 +08:00
parent 0087d5e5c6
commit 291d473cc3
6 changed files with 46 additions and 46 deletions

View File

@@ -1,11 +1,10 @@
package com.youlai.boot.common.annotation;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;
/**
* 接口限流
* <p>标注在 Controller 方法上,基于 Redis 计数窗口实现</p>
* <p>标注在 Controller 方法上,基于 Redis 滑动窗口实现</p>
*
* @author Ray.Hao
* @since 4.3.1
@@ -23,21 +22,9 @@ public @interface RateLimit {
int limit() default 0;
/**
* 滑动窗口大小。
* 滑动窗口大小(秒)
* <p>
* 单位由 {@link #timeUnit()} 决定;{@code <=0} 时使用全局默认值。
* {@code <=0} 时使用全局默认值 {@code rate-limit.default-window}
*/
int window() default 0;
/**
* 窗口单位,默认秒。
*/
TimeUnit timeUnit() default TimeUnit.SECONDS;
/**
* 限流 Key 的分组标签,用于区分不同接口。
* <p>
* 默认 {@code api}。
*/
String prefix() default "api";
}