/**
  * Handles -ERR responses returned by Redis.
  *
  * @param ConnectionInterface $connection The connection that returned the error.
  * @param ResponseErrorInterface $response The error response instance.
  */
 protected function onResponseError(ConnectionInterface $connection, ResponseErrorInterface $response)
 {
     // Force disconnection to prevent protocol desynchronization.
     $connection->disconnect();
     $message = $response->getMessage();
     throw new ServerException($message);
 }
Пример #2
0
 /**
  * Handles -ERR replies from Redis.
  *
  * @param CommandInterface $command Command that generated the -ERR reply.
  * @param ResponseErrorInterface $error Redis error reply object.
  * @return mixed
  */
 protected function handleServerError(CommandInterface $command, ResponseErrorInterface $error)
 {
     list($type, $details) = explode(' ', $error->getMessage(), 2);
     switch ($type) {
         case 'MOVED':
         case 'ASK':
             return $this->onMoveRequest($command, $type, $details);
         default:
             return $error;
     }
 }
Пример #3
0
 /**
  * Handles -ERR responses returned by Redis.
  *
  * @param  CommandInterface       $command Command that generated the -ERR response.
  * @param  ResponseErrorInterface $error   Redis error response object.
  * @return mixed
  */
 protected function onErrorResponse(CommandInterface $command, ResponseErrorInterface $error)
 {
     $details = explode(' ', $error->getMessage(), 2);
     switch ($details[0]) {
         case 'MOVED':
             return $this->onMovedResponse($command, $details[1]);
         case 'ASK':
             return $this->onAskResponse($command, $details[1]);
         default:
             return $error;
     }
 }
Пример #4
0
 /**
  * Handles -ERR responses returned by Redis.
  *
  * @param  CommandInterface       $command  The command that generated the error.
  * @param  ResponseErrorInterface $response The error response instance.
  * @return mixed
  */
 protected function onResponseError(CommandInterface $command, ResponseErrorInterface $response)
 {
     if ($command instanceof ScriptedCommand && $response->getErrorType() === 'NOSCRIPT') {
         $eval = $this->createCommand('eval');
         $eval->setRawArguments($command->getEvalArguments());
         $response = $this->executeCommand($eval);
         if (!$response instanceof ResponseObjectInterface) {
             $response = $command->parseResponse($response);
         }
         return $response;
     }
     if ($this->options->exceptions) {
         throw new ServerException($response->getMessage());
     }
     return $response;
 }