本文整理匯總了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();
}