RedisHandler class
Framework\Session\SaveHandlers\RedisHandler
Class RedisHandler.
Extends Framework\Session\SaveHandler
Implements:
SessionUpdateTimestampHandlerInterface, SessionHandlerInterface
Defined in libraries/session/src/SaveHandlers/RedisHandler.php
Properties #
- $redis
- -
$redis
protected ?Redis $redis
Methods #
- close()
- -
- destroy()
- -
- gc()
- -
- getRedis()
- -
- open()
- -
- read()
- -
- setRedis()
- -
- updateTimestamp()
- -
- write()
- -
- getKey()
- Get a key for Redis, using the optional prefix, match IP and match User-Agent configs.
- lock()
- -
- prepareConfig()
- Prepare configurations to be used by the RedisHandler.
- unlock()
- -
close()
public function close(): bool
Returns
bool
destroy()
public function destroy($id): bool
Parameters
- $id
Returns
bool
gc()
public function gc($max_lifetime): int|false
Parameters
- $max_lifetime
Returns
int|false
getRedis()
public function getRedis(): ?Redis
Returns
?Redis
open()
public function open($path, $name): bool
Parameters
- $path
- $name
Returns
bool
read()
public function read($id): string
Parameters
- $id
Returns
string
setRedis()
public function setRedis(Redis $redis): static
Parameters
- Redis $redis
Returns
static
updateTimestamp()
public function updateTimestamp($id, $data): bool
Parameters
- $id
- $data
Returns
bool
write()
public function write($id, $data): bool
Parameters
- $id
- $data
Returns
bool
getKey()
protected function getKey(string $id): string
Get a key for Redis, using the optional prefix, match IP and match User-Agent configs.
Parameters
- string $id - The session id
Returns
string
- The final key
lock()
protected function lock(string $id): bool
Parameters
- string $id
Returns
bool
prepareConfig()
protected function prepareConfig(array $config): void
Prepare configurations to be used by the RedisHandler.
Parameters
- array $config - Custom configs The custom configs are: ```php $configs = [ // A custom prefix prepended in the keys 'prefix' => '', // The Redis host 'host' => '127.0.0.1', // The Redis host port 'port' => 6379, // The connection timeout 'timeout' => 0.0, // Optional auth password 'password' => null, // Optional database to select 'database' => null, // Maximum attempts to try lock a session id 'lock_attempts' => 60, // Interval between the lock attempts in microseconds 'lock_sleep' => 1_000_000, // TTL to the lock (valid for the current session only) 'lock_ttl' => 600, // The maxlifetime (TTL) used for cache item expiration 'maxlifetime' => null, // Null to use the ini value of session.gc_maxlifetime // Match IP? 'match_ip' => false, // Match User-Agent? 'match_ua' => false, ]; ```
Returns
void
unlock()
protected function unlock(): bool
Returns
bool
Inherited methods #
-
__construct()fromFramework\Session\SaveHandler -
getConfig()fromFramework\Session\SaveHandler -
log()fromFramework\Session\SaveHandler -
setFingerprint()fromFramework\Session\SaveHandler -
hasSameFingerprint()fromFramework\Session\SaveHandler -
getMaxlifetime()fromFramework\Session\SaveHandler -
getIP()fromFramework\Session\SaveHandler -
getUA()fromFramework\Session\SaveHandler -
getKeySuffix()fromFramework\Session\SaveHandler -
validateId()fromFramework\Session\SaveHandler