Error:
app/cache/dev/appDevDebugProjectContainer.php - Linea: 880 - Redis server went away
I am using this bundle and what happens to me is that when the doctrine server is down the application stops working throwing me a 500 error. The idea would be that if the redis server is down, continue the program reading from the database, but this is not so because it gives me the error reported from the symfony log.
I currently have it injected as follows:
Global.utils:
Class: \ Common \ Utils
arguments: ["@ doctrine_cache.providers.redis"]
And I use the following functions to verify the existence of cache and to save in it:
Public function checkSiExistEnCache ($ key)
{
try {
$ redisCache-> setNamespace ('space-cache');
return $redisCache->fetch($key);
} catch (\Exception $e) {
//@todo logger
$this->logger->crit("Redis is down!!! on check");
return false;
}
}
Public function saveEnCache ($ key, $ data, $ ttl)
{
try {
$ redisCache-> setNamespace ('scrutiny-cache');
$ redisCache-> save ($ key, $ data, $ ttl);
}
catch (\Exception $e) {
//@todo logger
$this->logger->crit("Redis is down!!! on save");
return false;
}
I can not capture the exeption.
Now if instead of placing it in the service container services.YML
I get it through:
global.utils:
class: \Common\Utils
arguments: ["@service_container","@logger"]
public function chequearSiExisteEnCache($key)
{
try {
$redisCache = $this->container->get("doctrine_cache.providers.redis");
$redisCache->setNamespace('escrutinio-cache');
return $redisCache->fetch($key);
} catch (\Exception $e) {
//@todo logger
$this->logger->crit("Redis is down!!! on check");
return false;
}
}
Public function saveEnCache ($ key, $ data, $ ttl)
{
try {
$ redisCache = $ this-> container-> get ("doctrine_cache.providers.redis");
$ redisCache-> setNamespace ('space-cache');
return $ redisCache-> fetch ($ key);
} catch (\Exception $e) {
//@todo logger
$this->logger->crit("Redis is down!!! on save");
return false;
}
}
I can capture the exeption!!!
Here if I can capture the exeption and return true or false and continue reading the database if redis would be dropped.
What I would like to know is if this would be affecting the performance of the program, since every time I check the existence of cache, I am instantiating the bundle of redis and perhaps creating too many connections.
With the same bundle but using memcache I did not have this problem.
thanks and regards
Luke!