Skip to content

Commit f075dea

Browse files
[10.x] add getRedisConnection to ThrottleRequestsWithRedis (#47742)
* add getRedisConnection * comment: fix * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 700a0a8 commit f075dea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function handleRequest($request, Closure $next, array $limits)
8686
protected function tooManyAttempts($key, $maxAttempts, $decayMinutes)
8787
{
8888
$limiter = new DurationLimiter(
89-
$this->redis, $key, $maxAttempts, $decayMinutes * 60
89+
$this->getRedisConnection(), $key, $maxAttempts, $decayMinutes * 60
9090
);
9191

9292
return tap(! $limiter->acquire(), function () use ($key, $limiter) {
@@ -119,4 +119,14 @@ protected function getTimeUntilNextRetry($key)
119119
{
120120
return $this->decaysAt[$key] - $this->currentTime();
121121
}
122+
123+
/**
124+
* Get the Redis connection that should be used for throttling.
125+
*
126+
* @return \Illuminate\Redis\Connections\Connection
127+
*/
128+
protected function getRedisConnection()
129+
{
130+
return $this->redis->connection();
131+
}
122132
}

0 commit comments

Comments
 (0)