wanshenmean
2 天以前 2f7c7a0621ee2e84c47ccd054889a71e8ce4fdd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace WIDESEAWCS_RedisService.RateLimiting
{
    public interface IRateLimitingService
    {
        /// <summary>
        /// 固定窗口限流
        /// </summary>
        bool IsAllowed(string key, int maxRequests, TimeSpan window);
 
        /// <summary>
        /// 滑动窗口限流
        /// </summary>
        bool IsAllowedSliding(string key, int maxRequests, TimeSpan window);
 
        /// <summary>
        /// 令牌桶限流
        /// </summary>
        bool TryAcquireToken(string key, int maxTokens, int refillRate, TimeSpan refillInterval);
 
        /// <summary>
        /// 获取剩余请求数
        /// </summary>
        long GetRemainingRequests(string key, int maxRequests, TimeSpan window);
    }
}