ella123/hyperf-throttle
最新稳定版本:3.1.14
Composer 安装命令:
composer require ella123/hyperf-throttle
包简介
hyperf throttle rate limit
README 文档
README
适配 hyperf 框架的请求频率限流器。
安装依赖
composer require ella123/hyperf-throttle
发布配置
php bin/hyperf.php vendor:publish ella123/hyperf-throttle
注解说明
| 配置 | 默认值 | 说明 |
|---|---|---|
| limit | 60 | 限制频次 |
| timer | 60 | 时间周期(单位:s) |
| key | null | 标识Key(支持自定义回调) |
| callback | null | 超频回调(支持自定义回调) |
使用实例
- 支持类
- 支持方法
/** * 频率限制 */ #[\Ella123\HyperfThrottle\Annotation\Throttle(limit: 60,timer: 60)] class A { #[\Ella123\HyperfThrottle\Annotation\Throttle(limit: 60,timer: 60)] public function name() { } } /** * 重复提交 */ #[\Ella123\HyperfThrottle\Annotation\Resubmit(limit: 1,timer: 60)] class B { #[\Ella123\HyperfThrottle\Annotation\Resubmit(limit: 1,timer: 60)] public function submit() { } } /** * 短信限制(支持定义不同规则) */ #[\Ella123\HyperfThrottle\Annotation\SmsMinuteLimit(limit: 1,timer: 60)] #[\Ella123\HyperfThrottle\Annotation\SmsHourLimit(limit: 5,timer: 3600)] #[\Ella123\HyperfThrottle\Annotation\SmsDayLimit(limit: 15,timer: 86400)] class C { #[\Ella123\HyperfThrottle\Annotation\SmsMinuteLimit(limit: 1,timer: 60)] #[\Ella123\HyperfThrottle\Annotation\SmsHourLimit(limit: 5,timer: 3600)] #[\Ella123\HyperfThrottle\Annotation\SmsDayLimit(limit: 15,timer: 86400)] public function send() { } }
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-23