Esempio n. 1
0
 /**
  * @return array
  * @throws \Exception
  */
 public function writeToRedis()
 {
     if (!isset($this->pipeLine)) {
         throw new \Exception('No Redis Pipeline Set');
     }
     $results = $this->pipeLine->execute();
     $this->disconnectFromServer();
     return $results;
 }
 /**
  * @group disconnected
  */
 public function testExecuteWithCallableArgumentHandlesExceptions()
 {
     $exception = null;
     $connection = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $connection->expects($this->never())->method('writeCommand');
     $connection->expects($this->never())->method('readResponse');
     $pipeline = new PipelineContext(new Client($connection));
     $exception = null;
     $replies = null;
     try {
         $replies = $pipeline->execute(function ($pipe) {
             $pipe->echo('one');
             throw new ClientException('TEST');
             $pipe->echo('two');
         });
     } catch (\Exception $exception) {
         // NOOP
     }
     $this->assertInstanceOf('Predis\\ClientException', $exception);
     $this->assertSame('TEST', $exception->getMessage());
     $this->assertNull($replies);
 }
Esempio n. 3
0
 /**
  * Executes a pipeline context when a callable object is passed.
  *
  * @param array $options Options of the context initialization.
  * @param mixed $callable Optional callable object used to execute the context.
  * @return PipelineContext|array
  */
 private function pipelineExecute(PipelineContext $pipeline, $callable)
 {
     return isset($callable) ? $pipeline->execute($callable) : $pipeline;
 }