Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶
func NewRateLimiter(client *redis.Redis, limit int) *RateLimiter
func (*RateLimiter) AllowByDayRange ¶
func (r *RateLimiter) AllowByDayRange(key string) (bool, error)
AllowByDayRange 实现限制一天内的访问次数的逻辑
func (*RateLimiter) AllowByDuration ¶
func (r *RateLimiter) AllowByDuration(key string, windowSec int) (bool, error)
AllowByDuration 实现限制一段时间内的访问次数的逻辑
func (*RateLimiter) AllowByTimeRange ¶
func (r *RateLimiter) AllowByTimeRange(key string, startTime, endTime int64) (bool, error)
AllowByTimeRange 实现限制一个时间段内的访问次数的逻辑
Click to show internal directories.
Click to hide internal directories.