承接 symfony/rate-limiter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

symfony/rate-limiter

最新稳定版本:v8.0.0

Composer 安装命令:

composer require symfony/rate-limiter

包简介

Provides a Token Bucket implementation to rate limit input and output in your application

README 文档

README

The Rate Limiter component provides a Token Bucket implementation to rate limit input and output in your application.

Getting Started

composer require symfony/rate-limiter
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;
use Symfony\Component\RateLimiter\RateLimiterFactory;

$factory = new RateLimiterFactory([
    'id' => 'login',
    'policy' => 'token_bucket',
    'limit' => 10,
    'rate' => ['interval' => '15 minutes'],
], new InMemoryStorage());

$limiter = $factory->create();

// blocks until 1 token is free to use for this process
$limiter->reserve(1)->wait();
// ... execute the code

// only claims 1 token if it's free at this moment (useful if you plan to skip this process)
if ($limiter->consume(1)->isAccepted()) {
   // ... execute the code
}

Resources

统计信息

  • 总下载量: 42.1M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 266
  • 点击次数: 1
  • 依赖项目数: 111
  • 推荐数: 7

GitHub 信息

  • Stars: 263
  • Watchers: 6
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04