10000 Merge pull request #348 from coder-pm/dev-session-handler-shutdown · snc/SncRedisBundle@8e8ec51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e8ec51

Browse files
authored
Merge pull request #348 from coder-pm/dev-session-handler-shutdown
Session handler shutdown cleanup
2 parents f657fa8 + 52f417a commit 8e8ec51

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ class RedisSessionHandler implements \SessionHandlerInterface
7575
/**
7676
* Redis session storage constructor.
7777
*
78-
* @param \Predis\Client|\Redis $redis Redis database connection
79-
* @param array $options Session options
80-
* @param string $prefix Prefix to use when writing session data
78+
* @param \Predis\Client|\Redis $redis Redis database connection
79+
* @param array $options Session options
80+
* @param string $prefix Prefix to use when writing session data
81+
* @param bool $locking Indicates an sessions should be locked
82+
* @param int $spinLockWait Microseconds to wait between acquire lock tries
8183
*/
8284
public function __construct($redis, array $options = array(), $prefix = 'session', $locking = true, $spinLockWait = 150000)
8385
{
@@ -96,6 +98,8 @@ public function __construct($redis, array $options = array(), $prefix = 'session
9698
if (!$this->lockMaxWait) {
9799
$this->lockMaxWait = self::DEFAULT_MAX_EXECUTION_TIME;
98100
}
101+
102+
register_shutdown_function(array($this, 'shutdown'));
99103
}
100104

101105
/**
@@ -264,10 +268,9 @@ protected function getRedisKey($key)
264268
}
265269

266270
/**
267-
* Destructor.
271+
* Shutdown handler, replacement for class destructor as it might not be called.
268272
*/
269-
public function __destruct()
270-
{
273+
public function shutdown() {
271274
$this->close();
272275
}
273276
}

0 commit comments

Comments
 (0)
0