PHP code example of zeus / throttle

1. Go to this page and download the library: Download zeus/throttle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zeus / throttle example snippets


use Throttle\Throttle;
use Throttle\Time;



$throttle = new Throttle(
    new Time(60, 25)
);

$throttle->commit();


if ($throttle->isHasAccessLimit()) {
    print 'request can go next';
} else {
    print 'max request amount';
}





use Throttle\Throttle;
use Throttle\Time;
use Throttle\Redis;


Redis::setRedisClient(new \Predis\Client($params));

$throttle = new Throttle(
    new Time(60, 25)
);

$throttle->commit();


if ($throttle->isHasAccessLimit()) {
    print 'request can go next';
} else {
    print 'max request amount';
}



$throttle->getDetail()->toArray();