Здравствуйте, у меня есть проект, где я использую Redis в качестве службы кэширования. Я не знаю почему, но это замедляет инициализацию около 4 секунд. Вот код:
use Psr\Log\LoggerInterface;
use Symfony\Component\Cache\Adapter\RedisAdapter;
function init(string $redisAddress = null, $port = null,bool $useRedis = false)
{
$start = microtime(true);
$useRedis = true;
if ($useRedis == true) {
try{
$this->client = RedisAdapter::createConnection(
// provide a string dsn
'redis://'.$redisAddress.':'.$port,
// associative array of configuration options
[
'persistent' => 1,
'timeout' => 15,
]
);
if($this->client instanceof \Redis){
$this->client->connect($redisAddress,$port);
} else{
$this->client->connect();
}
if ($this->client->isConnected()) {
$this->useRedis = true;
}
} catch (\Exception $exception){
}
} else {
$this->useRedis = false;
}
$time_elapsed_secs = microtime(true) - $start;
echo round($time_elapsed_secs,2); die();
}
настройка системы:
php 7.2.2
apache 2,4
symfony приложение 3.3 включено режим prod
redis 2.4.5
windows 10
Что я делаю не так?