antikirra/rate-limiter
最新稳定版本:0.0.2
Composer 安装命令:
composer require antikirra/rate-limiter
包简介
README 文档
README
Install
composer require antikirra/rate-limiter
Basic usage
<?php use Antikirra\RateLimiter; require __DIR__ . '/vendor/autoload.php'; $redis = new Redis(); $redis->connect('127.0.0.1'); // maximum of three requests per minute $limiter = new RateLimiter($redis, "signin_by_ip{$_SERVER['REMOTE_ADDR']}", 3, 60, 0.75); $result = $limiter->check(); // returns the actual counter value without any side effects echo $result->getCount(); // (int) actual counter value print_r($result->isPassed()); // (bool) true - it's okay, false - flood has been detected!!! $result = $limiter->hit(); // increments the counter value, returning the result of the check echo $result->getCount(); // (int) updated counter value print_r($result->isPassed()); // (bool) true - it's okay, false - flood has been detected!!! print_r($result->isFailed()); // (bool) true - flood has been detected!!!, false - it's okay $limiter->reset(); // (void) resets counters to zero
统计信息
- 总下载量: 190
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-01-31