/** * {@inheritdoc} */ public function __construct(ClientInterface $client) { if (!$client->getProfile()->supportsCommands(array('multi', 'exec', 'discard'))) { throw new ClientException("The current profile does not support 'MULTI', 'EXEC' and 'DISCARD'."); } parent::__construct($client); }
/** * Checks if the passed client instance satisfies the required conditions * needed to initialize a monitor consumer. * * @param ClientInterface $client Client instance used by the consumer. * * @throws NotSupportedException */ private function assertClient(ClientInterface $client) { if ($client->getConnection() instanceof AggregateConnectionInterface) { throw new NotSupportedException('Cannot initialize a monitor consumer over aggregate connections.'); } if ($client->getProfile()->supportsCommand('MONITOR') === false) { throw new NotSupportedException("The current profile does not support 'MONITOR'."); } }
/** * Checks if the client instance satisfies the required conditions needed to * initialize a PUB/SUB consumer. * * @param ClientInterface $client Client instance used by the consumer. * * @throws NotSupportedException */ private function checkCapabilities(ClientInterface $client) { if ($client->getConnection() instanceof AggregateConnectionInterface) { throw new NotSupportedException('Cannot initialize a PUB/SUB consumer over aggregate connections.'); } $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe'); if ($client->getProfile()->supportsCommands($commands) === false) { throw new NotSupportedException('The current profile does not support PUB/SUB related commands.'); } }
/** * Configures the transaction using the provided options. * * @param ClientInterface $client Underlying client instance. * @param array $options Array of options for the transaction. **/ protected function configure(ClientInterface $client, array $options) { if (isset($options['exceptions'])) { $this->exceptions = (bool) $options['exceptions']; } else { $this->exceptions = $client->getOptions()->exceptions; } if (isset($options['cas'])) { $this->modeCAS = (bool) $options['cas']; } if (isset($options['watch']) && ($keys = $options['watch'])) { $this->watchKeys = $keys; } if (isset($options['retry'])) { $this->attempts = (int) $options['retry']; } }
/** * Ensures that the client supports the specified Redis command required to * fetch elements from the server to perform the iteration. * * @param ClientInterface $client Client connected to Redis. * @param string $commandID Command ID. * * @throws NotSupportedException */ protected function requiredCommand(ClientInterface $client, $commandID) { if (!$client->getProfile()->supportsCommand($commandID)) { throw new NotSupportedException("The current profile does not support '{$commandID}'."); } }