Class: Limit::RollingWindowRateLimiter
- Inherits:
-
BaseRateLimiter
- Object
- BaseRateLimiter
- Limit::RollingWindowRateLimiter
- Defined in:
- lib/limit.rb
Overview
RollingWindow Rate limiter, implemented using Sliding Log, allows n no of requests in a rolling window
Constant Summary
Constants inherited from BaseRateLimiter
BaseRateLimiter::REQUIRED_KEYS
Instance Attribute Summary
Attributes inherited from BaseRateLimiter
#identifier_prefix, #limit_calculator
Instance Method Summary collapse
Methods inherited from BaseRateLimiter
connection, #get_key, #initialize, load_script, logger
Constructor Details
This class inherits a constructor from Limit::BaseRateLimiter
Instance Method Details
#allowed?(key) ⇒ Boolean
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/limit.rb', line 165 def allowed?(key) limit_data = get_current_limit(key) result = eval_sha( [get_key(key)], [ limit_data[:window_seconds], limit_data[:max_requests] ] ) result == 1 end |