https://github.com/diloabininyeri/throttle
PHP HTTP rate limit library helps catch extremely unnecessary HTTP requests, allows you to manage a certain number of HTTP requests in a certain time frame
https://github.com/diloabininyeri/throttle
composer-package http php-library rate-limit redis throttle union
Last synced: 4 months ago
JSON representation
PHP HTTP rate limit library helps catch extremely unnecessary HTTP requests, allows you to manage a certain number of HTTP requests in a certain time frame
- Host: GitHub
- URL: https://github.com/diloabininyeri/throttle
- Owner: diloabininyeri
- Created: 2020-10-30T20:43:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-08T19:02:15.000Z (about 5 years ago)
- Last Synced: 2025-10-12T08:08:07.202Z (4 months ago)
- Topics: composer-package, http, php-library, rate-limit, redis, throttle, union
- Language: PHP
- Homepage:
- Size: 197 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.MD
Awesome Lists containing this project
README
#### PHP rate limit library with redis
install with composer
```console
composer require zeus/throttle
```
Sets http request limitations, such as only 100 accesses in 10 minutes
Powerful redis handles HTTP requests, you can easily integrate it into all api or projects
```php
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';
}
```
#### if you want to configure a redis client
```php
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';
}
```
Get detail
```php
$throttle->getDetail()->toArray();
```