Skip to content

Commit

Permalink
[10.x] Ability to configure default session block timeouts (#48795)
Browse files Browse the repository at this point in the history
* [10.x] Ability to configure default session block timeouts

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
bytestream and taylorotwell committed Oct 26, 2023
1 parent d5e8a9d commit 31e81e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Session/Middleware/StartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function handleRequestWhileBlocking(Request $request, $session, Closur

$lockFor = $request->route() && $request->route()->locksFor()
? $request->route()->locksFor()
: 10;
: $this->manager->defaultRouteBlockLockSeconds();

$lock = $this->cache($this->manager->blockDriver())
->lock('session:'.$session->getId(), $lockFor)
Expand All @@ -90,7 +90,7 @@ protected function handleRequestWhileBlocking(Request $request, $session, Closur
$lock->block(
! is_null($request->route()->waitsFor())
? $request->route()->waitsFor()
: 10
: $this->manager->defaultRouteBlockWaitSeconds()
);

return $this->handleStatefulRequest($request, $session, $next);
Expand Down
20 changes: 20 additions & 0 deletions src/Illuminate/Session/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ public function blockDriver()
return $this->config->get('session.block_store');
}

/**
* Get the maximum number of seconds the session lock should be held for.
*
* @return int
*/
public function defaultRouteBlockLockSeconds()
{
return $this->config->get('session.block_lock_seconds', 10);
}

/**
* Get the maximum number of seconds to wait while attempting to acquire a route block session lock.
*
* @return int
*/
public function defaultRouteBlockWaitSeconds()
{
return $this->config->get('session.block_wait_seconds', 10);
}

/**
* Get the session configuration.
*
Expand Down

0 comments on commit 31e81e1

Please sign in to comment.