How to do error handling and retries with Predis?

69 views Asked by At

I can't find any information regarding retrying/error handling when using Predis.

$attempt = 0;

do {
     try {
        $value = $this->client->get($key);
        return $value;
     } catch (\Exception $ex) {
        $this->client = new \Predis\Client();
     }

} while(++attempt <= $MAX_RECONNECT_ATTEMPTS);

Is it make sense to reinitialize the Predis client, in case of server failure for example? Or is it handle by the client itself?

0

There are 0 answers