public
Description: Simple plugin which allows you to throttle certain activities in your web apps. Uses memcached for speedy implementation and requires Rails 2.1+
Homepage: http://www.shopify.com
Clone URL: git://github.com/tobi/throttle.git
Tobias Lütke (author)
Thu May 01 15:04:03 -0700 2008
commit  16fe81a49aacb97c99b20a4faf9ba78942f5271c
tree    119c52122e1c29b5127cfa45e48c48808da021c7
parent  261638a1dd0ee45058661d311959cff3e1642503
name age message
file README Thu May 01 15:04:03 -0700 2008 added readme [Tobias Lütke]
directory lib/ Thu May 01 15:03:04 -0700 2008 Initial Checkin [Tobias Lütke]
README
Throttle arbituary operation. Once limit is reached it will raise a Throttle::LimitExeeded exception. 

Example: 

  Throttle.for("feed:#{request.remote_ip}", :max => 20, :in => 10.minutes) do
    render :xml => Articles.all
  end

  If you want to clear the timeout for the current block ( for example: fraud protection. Clear the throttle when 
  the submitted Credit Card was valid. ) your block can accept a yielded throttle object and call the clear method

  Throttle.for("cc:#{request.remote_ip}", :max => 20, :in => 10.minutes) do |throttle|
    if am.pay(@credit_card)        
      throttle.clear
      redirect_to :action => 'done'
    end
  end