suhayb/ratelimit

一个用于限制标识符运行代码的PHP包

2.1.0 2019-05-01 19:19 UTC

This package is auto-updated.

Last update: 2024-08-29 04:54:46 UTC


README

通用IP地址或任何数据的速率限制

安装

使用包管理器 composer 安装 RateLimit。

composer require suhayb/ratelimit

使用

<?php


include_once 'vendor/autoload.php';

use \Suhayb\RateLimit\RateLimit;
use \Suhayb\RateLimit\Adapters\ArrayAdapter;

# could be change to any data source compatible with RateLimitQuery interface 
$dataSource = new ArrayAdapter([]);
$rateLimit = new RateLimit(5, $dataSource);

# threw Max Limit Exception on exceeding the limit  
$rateLimit->run("10.11.13.1", function () {
        # do anything
});
    

贡献

欢迎提交拉取请求。对于重大更改,请首先打开一个问题来讨论您想要进行哪些更改。

请确保根据需要更新测试。

许可证

MIT