PeekableRequestRateLimiterInterface.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\RateLimiter;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\RateLimiter\RateLimit;
  13. /**
  14. * A request limiter which allows peeking ahead.
  15. *
  16. * This is valuable to reduce the cache backend load in scenarios
  17. * like a login when we only want to consume a token on login failure,
  18. * and where the majority of requests will be successful and thus not
  19. * need to consume a token.
  20. *
  21. * This way we can peek ahead before allowing the request through, and
  22. * only consume if the request failed (1 backend op). This is compared
  23. * to always consuming and then resetting the limit if the request
  24. * is successful (2 backend ops).
  25. *
  26. * @author Jordi Boggiano <j.boggiano@seld.be>
  27. */
  28. interface PeekableRequestRateLimiterInterface extends RequestRateLimiterInterface
  29. {
  30. public function peek(Request $request): RateLimit;
  31. }