PHP code example of mitirrli / limit
1. Go to this page and download the library: Download mitirrli/limit 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/ */
mitirrli / limit example snippets
$config = [
'second' => 60,//多少秒
'num' => 50,//接口请求次数
'redis' => [//redis配置
],
];
$limit = new Limit($config);//限制接口请求次数
if (!$limit->run()) return['1005', '当前接口请求次数已达上限,请稍后重试'];