限流器

目录

【注意】

详情参见:限流器open in new window

安装依赖

标准库地址open in new window

composer require hyperf/rate-limit

使用

#[GetMapping(path: 'rate/limit')]
#[RateLimit(create: 10, consume: 5, capacity: 50)]
public function rateLimit(): array
{
    return $this->result->setData([
        'QPS' => 5,
        'CREATE TOKEN PER SECOND' => 10,
        'CAPACITY' => 50,
    ])->getResult();
}