Fix rate limiter documentation

This commit is contained in:
Chi-teck 2020-12-02 05:17:58 +00:00 committed by Alexander M. Turek
parent 56e79395c4
commit f90f27b63a

View File

@ -20,13 +20,15 @@ $ composer require symfony/rate-limiter
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;
use Symfony\Component\RateLimiter\RateLimiterFactory;
$limiter = new 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