Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

DoctrineCacheBundle with Redis server went away #116

Closed
lucasaguilar opened this issue Jul 31, 2017 · 3 comments
Closed

DoctrineCacheBundle with Redis server went away #116

lucasaguilar opened this issue Jul 31, 2017 · 3 comments
Assignees

Comments

@lucasaguilar
Copy link

lucasaguilar commented Jul 31, 2017

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!

@alcaeus
Copy link
Member

alcaeus commented Nov 9, 2018

I assume #113 would work with that - there's just some disagreement over whether it's a useful feature or not. I'll see if we can come to a conclusion there or if it's something that should be solved directly in the cache library.

In the meantime, if you still have the original problem, could you please confirm if #113 fixes your issue?

@alcaeus
Copy link
Member

alcaeus commented May 29, 2019

Closing for lack of feedback and #156.

@alcaeus alcaeus closed this as completed May 29, 2019
@alcaeus alcaeus assigned alcaeus and unassigned lucasaguilar May 29, 2019
@lucasaguilar
Copy link
Author

Dear, sorry for the delay, the truth passed to me. In my experience, it is useful to be able to know the status of cache service in an integrated way in the library since it would allow this library to be injected correctly and to capture the exeption we could make the necessary decision.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants