本文整理汇总了PHP中Memcached::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::ping方法的具体用法?PHP Memcached::ping怎么用?PHP Memcached::ping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::ping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ping
/**
* Check if we are still connected to the cache server, reconnect if not.
*
* @return bool
*/
private function ping()
{
if (!$this->connected) {
return false;
}
switch (NN_CACHE_TYPE) {
case self::TYPE_REDIS:
try {
return (bool) $this->server->ping();
} catch (\RedisException $error) {
// nothing to see here, move along
}
break;
case self::TYPE_MEMCACHED:
$versions = $this->server->getVersion();
if ($versions) {
foreach ($versions as $version) {
if ($version != "255.255.255") {
return true;
}
}
}
break;
case self::TYPE_APC:
return true;
default:
return false;
}
$this->connect();
return $this->connected;
}
示例2: ping
/**
* Redis supports ping'ing the server, so use it.
*/
private function ping()
{
if ($this->isRedis === true) {
try {
return (bool) $this->server->ping();
} catch (\RedisException $error) {
$this->connect();
return $this->connected;
}
}
return true;
}