Sha256: 20dc568c8b95ee6269f55e92e48ff06b3aca60b24ce82635e41df28c07860602
Contents?: true
Size: 581 Bytes
Versions: 3
Compression:
Stored size: 581 Bytes
Contents
module Rack; module Throttle ## class TimeWindow < Limiter ## # Returns `true` if fewer than the maximum number of requests permitted # for the current window of time have been made. # # @param [Rack::Request] request # @return [Boolean] def allowed?(request) return true if whitelisted?(request) count = cache_get(key = cache_key(request)).to_i + 1 rescue 1 allowed = count <= max_per_window.to_i begin cache_set(key, count) allowed rescue => e allowed = true end end end end; end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-throttle-0.4.2 | lib/rack/throttle/time_window.rb |
rack-throttle-0.4.1 | lib/rack/throttle/time_window.rb |
rack-throttle-0.4.0 | lib/rack/throttle/time_window.rb |