/** * Checks if the driver supports publish/subscribe pattern. * * @return bool */ public function isPubSubSupported() { if ((double) $this->client->getProfile()->getVersion() >= 2.8) { return true; } return false; }
/** * Checks if the passed client instance satisfies the required conditions * needed to initialize a Publish / Subscribe context. * * @param Client Client instance used by the context. */ private function checkCapabilities(Client $client) { if (Helpers::isCluster($client->getConnection())) { throw new NotSupportedException('Cannot initialize a PUB/SUB context over a cluster of 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'); } }
/** * Checks if the passed client instance satisfies the required conditions * needed to initialize a transaction context. * * @param Client Client instance used by the context. */ private function checkCapabilities(Client $client) { if (Helpers::isCluster($client->getConnection())) { throw new NotSupportedException('Cannot initialize a MULTI/EXEC context over a cluster of connections'); } $profile = $client->getProfile(); if ($profile->supportsCommands(array('multi', 'exec', 'discard')) === false) { throw new NotSupportedException('The current profile does not support MULTI, EXEC and DISCARD'); } $this->canWatch = $profile->supportsCommands(array('watch', 'unwatch')); }
/** * @group disconnected */ public function testConstructorWithNullAndArrayArgument() { $factory = $this->getMock('Predis\\Connection\\ConnectionFactoryInterface'); $arg2 = array('profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $factory); $client = new Client(null, $arg2); $profile = $client->getProfile(); $this->assertSame($profile->getVersion(), ServerProfile::get('2.0')->getVersion()); $this->assertInstanceOf('Predis\\Command\\Processor\\KeyPrefixProcessor', $profile->getProcessor()); $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); $this->assertSame($factory, $client->getConnectionFactory()); }
/** * Sets the redis instance to use. * * @param \Predis\Client $redis */ public function setRedis(\Predis\Client $redis) { $this->_redis = $redis; $this->_supportsSetExpire = $redis->getProfile()->supportsCommand('setex'); }
/** * Checks if the passed client instance satisfies the required conditions * needed to initialize a monitor context. * * @param Client Client instance used by the context. */ private function checkCapabilities(Client $client) { if (Helpers::isCluster($client->getConnection())) { throw new ClientException('Cannot initialize a monitor context over a cluster of connections'); } if ($client->getProfile()->supportsCommand('monitor') === false) { throw new ClientException('The current profile does not support the MONITOR command'); } }