@@ -16,11 +16,11 @@ Symfony uses these rate limiters in built-in features like "login throttling",
1616which limits how many failed login attempts a user can make in a given period of
1717time, but you can use them for your own features too.
1818
19- Rate Limiting Strategies
20- ------------------------
19+ Rate Limiting Policies
20+ ----------------------
2121
22- Symfony's rate limiter implements some of the most common strategies to enforce
23- rate limits: **fixed window **, **sliding window ** and **token bucket **.
22+ Symfony's rate limiter implements some of the most common policies to enforce
23+ rate limits: **fixed window **, **sliding window **, **token bucket **.
2424
2525Fixed Window Rate Limiter
2626~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -86,12 +86,12 @@ enforce different levels of service (free or paid):
8686 framework :
8787 rate_limiter :
8888 anonymous_api :
89- # use 'sliding_window' if you prefer that strategy
90- strategy : ' fixed_window'
89+ # use 'sliding_window' if you prefer that policy
90+ policy : ' fixed_window'
9191 limit : 100
9292 interval : ' 60 minutes'
9393 authenticated_api :
94- strategy : ' token_bucket'
94+ policy : ' token_bucket'
9595 limit : 5000
9696 rate : { interval: '15 minutes', amount: 500 }
9797
@@ -124,13 +124,13 @@ the number of requests to the API::
124124
125125 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
126126 use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
127- use Symfony\Component\RateLimiter\RateLimiter ;
127+ use Symfony\Component\RateLimiter\RateLimiterFactory ;
128128
129129 class ApiController extends AbstractController
130130 {
131131 // if you're using service autowiring, the variable name must be:
132132 // "rate limiter name" (in camelCase) + "limiter" suffix
133- public function index(RateLimiter $anonymousApiLimiter)
133+ public function index(RateLimiterFactory $anonymousApiLimiter)
134134 {
135135 // create a limiter based on a unique identifier of the client
136136 // (e.g. the client's IP address, a username/email, an API key, etc.)
@@ -171,11 +171,11 @@ using the ``reserve()`` method::
171171
172172 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
173173 use Symfony\Component\HttpFoundation\Request;
174- use Symfony\Component\RateLimiter\RateLimiter ;
174+ use Symfony\Component\RateLimiter\RateLimiterFactory ;
175175
176176 class ApiController extends AbstractController
177177 {
178- public function registerUser(Request $request, RateLimiter $authenticatedApiLimiter)
178+ public function registerUser(Request $request, RateLimiterFactory $authenticatedApiLimiter)
179179 {
180180 $apiKey = $request->headers->get('apikey');
181181 $limiter = $authenticatedApiLimiter->create($apiKey);
@@ -229,11 +229,11 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the
229229
230230 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
231231 use Symfony\Component\HttpFoundation\Response;
232- use Symfony\Component\RateLimiter\RateLimiter ;
232+ use Symfony\Component\RateLimiter\RateLimiterFactory ;
233233
234234 class ApiController extends AbstractController
235235 {
236- public function index(RateLimiter $anonymousApiLimiter)
236+ public function index(RateLimiterFactory $anonymousApiLimiter)
237237 {
238238 $limiter = $anonymousApiLimiter->create($request->getClientIp());
239239 $limit = $limiter->consume();
0 commit comments