class

RateLimiter::Bucket(K)

Inherits Reference < Object

A Bucket collects rate limit queries and handle rate limiting logic

Constructors

new(limit : UInt32, time_span : Time::Span, delay : Time::Span = 0.seconds)

Creates a new bucket that enforces a limit within a time_span, optionally enforcing a minimum delay between queries.

Source

Instance methods

clean(rate_limit_time = nil)

Cleans the bucket, removing all elements that aren't necessary anymore. Accepts a Time to base the cleaning on, only useful for testing.

Source
rate_limited?(key : K, rate_limit_time = nil)

Performs a rate limit request on a certain key

Source

Nested types