redis流控测试

This commit is contained in:
2024-06-20 18:43:27 +08:00
parent 54a77d170a
commit 545523e324
5 changed files with 21 additions and 18 deletions

View File

@ -26,7 +26,7 @@ type IRateLimit interface {
// Month(ctx context.Context, key string, total, rate int) (bool, error) // 每月访问次数限制
// Year(ctx context.Context, key string, total, rate int) (bool, error) // 每年访问次数限制
// Custom(ctx context.Context, timeInfo int64, key string, total, rate int) (bool, error) // 自定义指定时间内的访问次数, timeInfo 单位 : s
SetRedisClient(client *redis.ClusterClient) // 设置redis客户端
SetRedisClient(client *redis.Client) // 设置redis客户端
AllowN(ctx context.Context, limitCfg *define.LimitConfig, tokenCnt int) (bool, error) // 申请N个令牌, N >= 0
Reset(ctx context.Context, limitCfg *define.LimitConfig) error // 重置
}