我试图抓住
\Predis\Connection\ConnectionException
在symfony应用程序中,但由于某种原因它无法正常工作。
所有涉及缓存的代码部分都在try catch块中:
try {
$client = new PredisClient(getenv('CACHE_SERVER'));
$this->cache = new PredisCache($client);
} catch (\Predis\Connection\ConnectionException | \ErrorException $e) {
// If no redis cache available, use file cache
$this->log->addInfo('problems with reading from redis cache, temporarily use file system cache');
}
以及从缓存中读取时
try {
if ($result_cache = $this->cache->fetch($cacheid)) {
return $result_cache;
}
} catch (\Predis\Connection\ConnectionException | \ErrorException $e) {
// forget the result and go on with database query
$this->log->addInfo('problems with reading from redis cache, getting the result from the database');
}
但是有时候会出现这样的错误:
Uncaught PHP Exception Predis\Connection\ConnectionException: "Error while reading line from the server. [tls://<NAME_OF_REDIS_SERVER:6380]" at /var/www/projec1/vendor/predis/predis/src/Connection/AbstractConnection.php line 155 {"exception":"[object] (Predis\\Connection\\ConnectionException(code: 0):
我想知道这个异常,因为在代码中捕获了Predis \ Connection \ ConnectionException,但是似乎在AbstractConnection.php中,尝试/捕获了上面的代码。
如果有人有主意...
问候 托马斯