/** * @inheritdoc */ public function execute(CommandInterface $command) { if (!$this->isConnected()) { throw new ConnectionException('No connection established'); } return $this->client->executeRaw(array_merge([$command->getCommand()], $command->getArguments())); }
/** * @inheritDoc */ public function getAll() : array { if (!$this->client->exists($this->key)) { $models = $this->repository->getAll(); if ($models) { $this->client->hmset($this->key, $this->repository->getAllIndexed()); } } else { $models = []; $data = $this->client->executeRaw(['HGETALL', $this->key]); for ($i = 0; $i < count($data); ++$i) { /** @var DirectoryView $viewClass */ $viewClass = $this->viewClass; $models[] = $viewClass::create($data[$i], $data[++$i]); } } return $models; }
/** * @group disconnected */ public function testRawCommandNeverThrowsExceptions() { $message = 'ERR Mock error response'; $response = new Response\Error($message); $connection = $this->getMock('Predis\\Connection\\ConnectionInterface'); $connection->expects($this->once())->method('executeCommand')->with($this->isRedisCommand('PING'))->will($this->returnValue($response)); $client = new Client($connection, array('exceptions' => true)); $this->assertSame($message, $client->executeRaw(array('PING'), $error)); $this->assertTrue($error); }