- Модуль: security
- Путь к файлу: ~/bitrix/modules/security/classes/general/session_redis.php
- Класс: CSecuritySessionRedis
- Вызов: CSecuritySessionRedis::newConnection
static function newConnection()
{
$result = false;
$exception = null;
if (!extension_loaded('redis'))
{
$result = false;
$exception = new ErrorException("redis extention not loaded.", 0, E_USER_ERROR, __FILE__, __LINE__);
}
if (!$exception)
{
if (!self::isStorageEnabled())
{
$result = false;
$exception = new ErrorException("BX_SECURITY_SESSION_REDIS_HOST constant is not defined.", 0, E_USER_ERROR, __FILE__, __LINE__);
}
}
if (!$exception)
{
$port = defined("BX_SECURITY_SESSION_REDIS_PORT")? intval(BX_SECURITY_SESSION_REDIS_PORT): 11211;
self::$connection = new Redis();
$result = self::$connection->pconnect(BX_SECURITY_SESSION_REDIS_HOST, $port);
if ($result)
{
self::$connection->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
}
else
{
$error = error_get_last();
if ($error && $error["type"] == E_WARNING)
{
$exception = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
}
}
}
if ($exception)
{
$application = BitrixMainApplication::getInstance();
$exceptionHandler = $application->getExceptionHandler();
$exceptionHandler->writeToLog($exception);
}
return $result;
}