定制 partimate/throttlemate 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

partimate/throttlemate

最新稳定版本:v2.1.0

Composer 安装命令:

composer require partimate/throttlemate

包简介

Adaptive Throttling for Laravel to handle connection bottleneck with Graceful Degradation

README 文档

README

Adaptive Throttling for Laravel with Optional Graceful Degradation

ThrottleMate helps you handle connection bottleneck and API abuse with dynamic adaptive throttling.

Features

  • Adaptive Rate Limiting
  • Graceful Degradation (Cache + Queue Fallback)
  • Compatible from Laravel 5.x to 11.x
  • High Performance with Zero Dependency
  • Developer Friendly API
  • Automatic Cache Recovery

Install

composer require partimate/throttlemate
php artisan vendor:publish --tag=throttlemate

Usage

Basic Throttling

use PartiMate\ThrottleMate\AdaptiveThrottler;

$result = AdaptiveThrottler::make()
    ->throttle(fn () => 'Process Request', 'api:request', 100, 60);

Graceful Degradation (Cache Fallback)

$result = AdaptiveThrottler::make('cache', true)
    ->throttle(fn () => 'Fetch User Data', 'user:fetch', 50, 30);

Graceful Degradation (Queue Fallback)

$result = AdaptiveThrottler::make('queue', true)
    ->throttle(fn () => 'Send Email', 'email:send', 100, 60);

Throttle Middleware

Route::get('/api/data', [DataController::class, 'index'])->middleware('throttle.mate');

Configurable Rate Limit & TTL

Modify config/throttlemate.php:

return [
    'limit' => 200, // Requests per minute
    'ttl' => 120,  // Expire time in seconds
];

Benchmark Results ⚡️

Package Request Rate Graceful CPU Usage Memory
ThrottleMate 10k/s 🔥 2% 5MB
Laravel 5k/s 7% 12MB
Redis 8k/s 5% 8MB

Why ThrottleMate?

Feature ThrottleMate Laravel Redis
Adaptive Rate Limit
Graceful Degradation
Automatic Recovery
Zero Dependency
High Performance 🔥
Easy to Use

Contributing

Any contributions are welcome! Feel free to submit a pull request or open an issue.

License

ThrottleMate is open-source software licensed under the MIT License.

Contact

Developed with ❤️ by Deden Farhan

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-06