Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added example and reference
  • Loading branch information
touhonoob committed May 16, 2015
1 parent 5dfbecd commit 655a9a6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,22 @@
[![Code Climate](https://codeclimate.com/github/touhonoob/RateLimit/badges/gpa.svg)](https://codeclimate.com/github/touhonoob/RateLimit)
# RateLimit
Rate Limiting Library With Token Bucket Algorithm

Reference: http://stackoverflow.com/a/668327/670662
# Example
````php
use \Touhonoob\RateLimit\RateLimit;
use \Touhonoob\RateLimit\Adapter\APC as RateLimitAdapterAPC;
use \Touhonoob\RateLimit\Adapter\Redis as RateLimitAdapterRedis;

$adapter = new RateLimitAdapterAPC(); // Use APC as Storage
// $adapter = new RateLimitAdapterRedis(); // Use Redis as Storage
$rateLimit = new RateLimit("myratelimit", "100", 3600, $adapter); // 100 Requests / Hour

$ip = $_SERVER['REMOTE_ADDR'];
if ($rateLimit->check($ip)) {
echo "passed";
} else {
echo "rate limit exceeded";
}
````

0 comments on commit 655a9a6

Please sign in to comment.