Sha256: 66baaa7a569c0d7a95482f792228c6b73db3c4063a3555229524bf02e0987cd9

Contents?: true

Size: 538 Bytes

Versions: 11

Compression:

Stored size: 538 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)
      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

11 entries across 11 versions & 4 rubygems

Version Path
improved-rack-throttle-0.9.0 lib/rack/throttle/limiters/time_window.rb
improved-rack-throttle-0.8.0 lib/rack/throttle/limiters/time_window.rb
improved-rack-throttle-w-expiry-0.8.0 lib/rack/throttle/limiters/time_window.rb
improved-rack-throttle-0.7.1 lib/rack/throttle/limiters/time_window.rb
improved-rack-throttle-0.7.0 lib/rack/throttle/limiters/time_window.rb
improved-rack-throttle-0.6.0 lib/rack/throttle/time_window.rb
improved-rack-throttle-0.5.0 lib/rack/throttle/time_window.rb
viximo-rack-throttle-0.5.0 lib/rack/throttle/time_window.rb
viximo-rack-throttle-0.4.0 lib/rack/throttle/time_window.rb
railslove-rack-throttle-0.0.1 lib/rack/throttle/time_window.rb
railslove-rack-throttle-0.0.0 lib/rack/throttle/time_window.rb