codeages / token-bucket
Token Bucket.
v0.1.0
2016-12-13 06:54 UTC
Requires
- doctrine/dbal: >=2.5.0
- psr/log: 1.0.0
- robmorgan/phinx: >=0.5.0
This package is auto-updated.
Last update: 2024-12-06 17:48:43 UTC
README
- use composer
composer require codeages/token-bucket
notice
- add redis mux key support for concurrency
- remove the db support
Usage
- example
$tokens = 30; //the bucket capacity $rates = 10; //recover tokens per second $consume = 10; //consume tokens $key = "test"; //bucket name $redis = new \Redis(); $redis->connect('127.0.0.1', 6379, 1); $driver = new RedisDriver("test", $redis); $tokenBucket = new TokenBucket($tokens, $rates, $name); $tokenBucket->setDriver($driver)->watch(); $tokenBucket->consume($consume);