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