本文整理汇总了PHP中Predis\Client::isConnected方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::isConnected方法的具体用法?PHP Client::isConnected怎么用?PHP Client::isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::isConnected方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Creates a connect to Redis or Sentinel using the Predis\Client object. It proxies the connecting and converts
* specific client exceptions to more generic adapted ones in PSRedis
*
* @throws \PSRedis\Exception\ConnectionError
*/
public function connect()
{
try {
$this->predisClient = $this->predisClientFactory->createClient($this->clientType, $this->getPredisClientParameters());
$this->predisClient->connect();
$this->isConnected = $this->predisClient->isConnected();
} catch (ConnectionException $e) {
throw new ConnectionError($e->getMessage());
}
}
示例2: __construct
/**
* Create a new Sentinel Monitor.
*
* If more than one sentinel server parameters are provided, the first
* sentinel that connects will be used for retrival of information.
*
* @param mixed $connection_params
*/
public function __construct($connection_params = null)
{
foreach ($connection_params as $connection) {
$this->client = new Client($connection);
// Usable connection is found
if ($this->client->isConnected()) {
break;
}
}
}
示例3: checkConnection
/**
* @return bool
*/
public function checkConnection()
{
if (!$this->predis->isConnected()) {
try {
$this->predis->connect();
return true;
} catch (ConnectionException $e) {
return false;
}
}
return true;
}
示例4: getConnection
/**
* This method cannot be overridden because you need to override \Hoard\AbstractPool::getAdapterOptions().
* @return \Predis\Client
*/
protected final function getConnection()
{
// set the servers to use with this connection
$servers = array();
if (array_key_exists('servers', $this->adapterOptions)) {
$servers = $this->adapterOptions['servers'];
}
// first time connect
if (null == $this->connection || !$this->connection->isConnected()) {
$this->connection = new PredisClient($servers);
}
return $this->connection;
}
示例5: testIsConnectedChecksConnectionState
/**
* @group disconnected
*/
public function testIsConnectedChecksConnectionState()
{
$connection = $this->getMock('Predis\\Connection\\ConnectionInterface');
$connection->expects($this->once())->method('isConnected');
$client = new Client($connection);
$client->isConnected();
}
示例6: isConnected
/**
* @inheritdoc
*/
public function isConnected()
{
return isset($this->client) && $this->client->isConnected();
}