Easy Rails controller rate limiting with Rails.cache
15-Nov-2024 103
This makes use of Rails.cache to store a key for 20 seconds. If the method is hit again while the key exists, we return an error. Otherwise we allow the operation to complete.
This is a quick and easy way to add a simple rate limit to a controller. For more advanced scenarios I typically use Rack Attack.
Easy Rails controller rate limiting with Rails.cache #ruby #rubydeveloper #rubyonrails #Rails #controller #limiting #Rails.cache https://rubyonrails.ba/link/easy-rails-controller-rate-limiting-with-rails-cache