Permalink
Browse files

Added some code examples.

  • Loading branch information...
bendiken committed Mar 21, 2010
1 parent 681cc04 commit b96ead336fa11109767d2ebbaf28a9e12d20c8f0
Showing with 17 additions and 0 deletions.
  1. +17 −0 README.md
View
@@ -6,6 +6,23 @@ rate-limiting incoming HTTP requests to your Rack application.
* <http://github.com/datagraph/rack-throttle>
+Examples
+--------
+
+ require 'rack/throttle'
+
+### Enforcing a 3-second delay between requests
+
+ use Rack::Throttle::Interval, :min => 3.0
+
+ run lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, world!\n"] }
+
+### Using a Memcached server to store rate-limiting counters
+
+ use Rack::Throttle::Interval, :min => 3.0, :cache => Memcached.new
+
+ run lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, world!\n"] }
+
Documentation
-------------

0 comments on commit b96ead3

Please sign in to comment.