10000 Session handler shutdown cleanup by coder-pm · Pull Request #348 · snc/SncRedisBundle · GitHub
[go: up one dir, main page]

Skip to content

Session handler shutdown cleanup #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replaced session handler destructor with shutdown function (which is …
…called even in case of fatal error or reaching maximum execution time)
  • Loading branch information
coder-pm committed May 30, 2017
commit 52f417a8e7d0d1f9b39ab6cc69659467ca16a0c1
15 changes: 9 additions & 6 deletions Session/Storage/Handler/RedisSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class RedisSessionHandler implements \SessionHandlerInterface
/**
* Redis session storage constructor.
*
* @param \Predis\Client|\Redis $redis Redis database connection
* @param array $options Session options
* @param string $prefix Prefix to use when writing session data
* @param \Predis\Client|\Redis $redis Redis database connection
* @param array $options Session options
* @param string $prefix Prefix to use when writing session data
* @param bool $locking Indicates an sessions should be locked
* @param int $spinLockWait Microseconds to wait between acquire lock tries
*/
public function __construct($redis, array $options = array(), $prefix = 'session', $locking = true, $spinLockWait = 150000)
{
Expand All @@ -96,6 +98,8 @@ public function __construct($redis, array $options = array(), $prefix = 'session
if (!$this->lockMaxWait) {
$this->lockMaxWait = self::DEFAULT_MAX_EXECUTION_TIME;
}

register_shutdown_function(array($this, 'shutdown'));
}

/**
Expand Down Expand Up @@ -262,10 +266,9 @@ protected function getRedisKey($key)
}

/**
* Destructor.
* Shutdown handler, replacement for class destructor as it might not be called.
*/
public function __destruct()
{
public function shutdown() {
$this->close();
}
}
0