method
rate_limiting
v8.1.1 -
Show latest stable
- Class:
ActionController::RateLimiting
rate_limiting(to:, within:, by:, with:, store:, name:, scope:)private
No documentation available.
# File actionpack/lib/action_controller/metal/rate_limiting.rb, line 72
def rate_limiting(to,, within,, by,, with,, store,, name,, scope))
by = by.is_a?(Symbol) ? send(by) : instance_exec(&by)
cache_key = ["rate-limit", scope, name, by].compact.join(":")
count = store.increment(cache_key, 1, expires_in: within)
if count && count > to
ActiveSupport::Notifications.instrument("rate_limit.action_controller",
request: request,
count: count,
to: to,
within: within,
by: by,
name: name,
scope: scope,
cache_key: cache_key) do
with.is_a?(Symbol) ? send(with) : instance_exec(&with)
end
end
end