// 判断key是否存在
$check = $this->redis->exists('qps_' . $appid);
if ($check){
// +1
$this->redis->incr('qps_' . $appid);
$count = $this->redis->get('qps_' . $appid);
// 限制每分钟30次
if($count > 30){
Help::print_json(100, '当前appid请求频率过高');
}
} else {
$this->redis->set('qps_' . $appid, 1);//初始值1
$this->redis->expire('qps_' . $appid, 60);//有效期一分钟
}
PHP使用redis限制接口每分钟请求次数 一分钟可请求多少次
猜你喜欢
转载自blog.csdn.net/qq_38832501/article/details/104397466
今日推荐
周排行