Ejemplo n.º 1
0
 /**
  * Handles -ERR responses returned by Redis.
  *
  * @param CommandInterface       $command  Redis command that generated the error.
  * @param ErrorResponseInterface $response Instance of the error response.
  *
  * @throws ServerException
  *
  * @return mixed
  */
 protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response)
 {
     if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
         $eval = $this->createCommand('EVAL');
         $eval->setRawArguments($command->getEvalArguments());
         $response = $this->executeCommand($eval);
         if (!$response instanceof ResponseInterface) {
             $response = $command->parseResponse($response);
         }
         return $response;
     }
     if ($this->options->exceptions) {
         throw new ServerException($response->getMessage());
     }
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Handles -ERR responses returned by Redis.
  *
  * @param CommandInterface       $command Command that generated the -ERR response.
  * @param ErrorResponseInterface $error   Redis error response object.
  *
  * @return mixed
  */
 protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $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;
     }
 }
Ejemplo n.º 3
0
 /**
  * Throws an exception on -ERR responses returned by Redis.
  *
  * @param ConnectionInterface    $connection Redis connection that returned the error.
  * @param ErrorResponseInterface $response   Instance of the error response.
  *
  * @throws ServerException
  */
 protected function exception(ConnectionInterface $connection, ErrorResponseInterface $response)
 {
     $connection->disconnect();
     $message = $response->getMessage();
     throw new ServerException($message);
 }