130 lines
3 KiB
YAML
130 lines
3 KiB
YAML
name: ThrottleRequestsWithRedis
|
|
class_comment: null
|
|
dependencies:
|
|
- name: Closure
|
|
type: class
|
|
source: Closure
|
|
- name: RateLimiter
|
|
type: class
|
|
source: Illuminate\Cache\RateLimiter
|
|
- name: Redis
|
|
type: class
|
|
source: Illuminate\Contracts\Redis\Factory
|
|
- name: DurationLimiter
|
|
type: class
|
|
source: Illuminate\Redis\Limiters\DurationLimiter
|
|
properties:
|
|
- name: redis
|
|
visibility: protected
|
|
comment: '# * The Redis factory implementation.
|
|
|
|
# *
|
|
|
|
# * @var \Illuminate\Contracts\Redis\Factory'
|
|
- name: decaysAt
|
|
visibility: public
|
|
comment: '# * The timestamp of the end of the current duration by key.
|
|
|
|
# *
|
|
|
|
# * @var array'
|
|
- name: remaining
|
|
visibility: public
|
|
comment: '# * The number of remaining slots by key.
|
|
|
|
# *
|
|
|
|
# * @var array'
|
|
methods:
|
|
- name: __construct
|
|
visibility: public
|
|
parameters:
|
|
- name: limiter
|
|
- name: redis
|
|
comment: "# * The Redis factory implementation.\n# *\n# * @var \\Illuminate\\Contracts\\\
|
|
Redis\\Factory\n# */\n# protected $redis;\n# \n# /**\n# * The timestamp of the\
|
|
\ end of the current duration by key.\n# *\n# * @var array\n# */\n# public $decaysAt\
|
|
\ = [];\n# \n# /**\n# * The number of remaining slots by key.\n# *\n# * @var array\n\
|
|
# */\n# public $remaining = [];\n# \n# /**\n# * Create a new request throttler.\n\
|
|
# *\n# * @param \\Illuminate\\Cache\\RateLimiter $limiter\n# * @param \\Illuminate\\\
|
|
Contracts\\Redis\\Factory $redis\n# * @return void"
|
|
- name: handleRequest
|
|
visibility: protected
|
|
parameters:
|
|
- name: request
|
|
- name: next
|
|
- name: limits
|
|
comment: '# * Handle an incoming request.
|
|
|
|
# *
|
|
|
|
# * @param \Illuminate\Http\Request $request
|
|
|
|
# * @param \Closure $next
|
|
|
|
# * @param array $limits
|
|
|
|
# * @return \Symfony\Component\HttpFoundation\Response
|
|
|
|
# *
|
|
|
|
# * @throws \Illuminate\Http\Exceptions\ThrottleRequestsException'
|
|
- name: tooManyAttempts
|
|
visibility: protected
|
|
parameters:
|
|
- name: key
|
|
- name: maxAttempts
|
|
- name: decaySeconds
|
|
comment: '# * Determine if the given key has been "accessed" too many times.
|
|
|
|
# *
|
|
|
|
# * @param string $key
|
|
|
|
# * @param int $maxAttempts
|
|
|
|
# * @param int $decaySeconds
|
|
|
|
# * @return mixed'
|
|
- name: calculateRemainingAttempts
|
|
visibility: protected
|
|
parameters:
|
|
- name: key
|
|
- name: maxAttempts
|
|
- name: retryAfter
|
|
default: 'null'
|
|
comment: '# * Calculate the number of remaining attempts.
|
|
|
|
# *
|
|
|
|
# * @param string $key
|
|
|
|
# * @param int $maxAttempts
|
|
|
|
# * @param int|null $retryAfter
|
|
|
|
# * @return int'
|
|
- name: getTimeUntilNextRetry
|
|
visibility: protected
|
|
parameters:
|
|
- name: key
|
|
comment: '# * Get the number of seconds until the lock is released.
|
|
|
|
# *
|
|
|
|
# * @param string $key
|
|
|
|
# * @return int'
|
|
- name: getRedisConnection
|
|
visibility: protected
|
|
parameters: []
|
|
comment: '# * Get the Redis connection that should be used for throttling.
|
|
|
|
# *
|
|
|
|
# * @return \Illuminate\Redis\Connections\Connection'
|
|
traits:
|
|
- Closure
|
|
- Illuminate\Cache\RateLimiter
|
|
- Illuminate\Redis\Limiters\DurationLimiter
|
|
interfaces: []
|