Download the PHP package fustundag/tokenbucket without Composer
On this page you can find all versions of the php package fustundag/tokenbucket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fustundag/tokenbucket
More information about fustundag/tokenbucket
Files in fustundag/tokenbucket
Package tokenbucket
Short Description PHP TokenBucket implementation for rate limit
License MIT
Homepage http://github.com/fustundag/tokenbucket
Informations about the package tokenbucket
TokenBucket 
TokenBucket is an algorithm for rate limit
You can check algorithm from http://en.wikipedia.org/wiki/Token_bucket
Usage
Basic usage
Options
capacity : Max token count of bucket.
fillRate : Token count to fill per second. For example if capacity is 20 and fillRate is 5, 5 tokens will added to bucket every second. But, total token cannot be exceed 20.
ttl : Time to live for bucket in seconds. If not given or zero given, it will be calculated automatically according to capacity and fillRate. ttl can be used to reset bucket with capacity. For example: if capacity is 100 and fillRate is zero and ttl is 300, 100 token can be consumed at 300 seconds. After 300 seconds, bucket will be reset to capacity.
Rate Limit Http Headers
You can get http headers for rate limit with getRateLimitHttpHeaders method:
X-RateLimit-Limit : gives capacity of bucket
X-RateLimit-Remaining : allowed token count of bucket
X-RateLimit-Reset : time to live of bucket
Contributing
You can contribute by forking the repo and creating pull requests. You can also create issues or feature requests.
License
This project is licensed under the MIT license. LICENSE file can be found in this repository.
All versions of tokenbucket with dependencies
ext-memcached Version *