Documentation ¶
Overview ¶
Package ratelimilib is for rate limit any strategy operations
As a quick start:
client, err := redislib.NewGORedisClient(redislib.GORedisConfig{URL: "redis://localhost:6379"}, nil) if err != nil { panic(err) } limiter := ratelimitlib.NewSlideWindowRateLimiter(client, 5, 30 * time.Second) t := time.Now().UnixNano() count, err := limiter.Incr(context.Background(), "kenny", t) if err != nil { panic(err) } fmt.Println(count)
Index ¶
Constants ¶
View Source
const SlideWindowIncrLuaScript = `` /* 437-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type SlideWindowRateLimiter ¶
type SlideWindowRateLimiter struct {
// contains filtered or unexported fields
}
func NewSlideWindowRateLimiter ¶
func NewSlideWindowRateLimiter(client *redislib.GORedisClient, capacity int64, interval time.Duration) *SlideWindowRateLimiter
Click to show internal directories.
Click to hide internal directories.