本文整理汇总了PHP中Memcache::quit方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::quit方法的具体用法?PHP Memcache::quit怎么用?PHP Memcache::quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::quit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Performs the test.
*
* @return \Jyxo\Beholder\Result
*/
public function run() : \Jyxo\Beholder\Result
{
// The memcached or memcache extension is required
if (!extension_loaded('memcached') && !extension_loaded('memcache')) {
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension memcached or memcache required');
}
$random = md5(uniqid((string) time(), true));
$key = 'beholder-' . $random;
$value = $random;
// Status label
$description = (false !== filter_var($this->host, FILTER_VALIDATE_IP) ? gethostbyaddr($this->host) : $this->host) . ':' . $this->port;
if (extension_loaded('memcached')) {
// Connection
$memcached = new \Memcached();
if (false === $memcached->addServer($this->host, $this->port)) {
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Connection error %s', $description));
}
} else {
// Connection (@ due to notice)
$memcached = new \Memcache();
if (false === @$memcached->connect($this->host, $this->port)) {
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Connection error %s', $description));
}
}
// Saving
if (false === $memcached->set($key, $value)) {
if ($memcached instanceof \Memcached) {
$memcached->quit();
} else {
$memcached->close();
}
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Write error %s', $description));
}
// Check
$check = $memcached->get($key);
if (false === $check || $check !== $value) {
if ($memcached instanceof \Memcached) {
$memcached->quit();
} else {
$memcached->close();
}
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Read error %s', $description));
}
// Deleting
if (false === $memcached->delete($key)) {
if ($memcached instanceof \Memcached) {
$memcached->quit();
} else {
$memcached->close();
}
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, sprintf('Delete error %s', $description));
}
// Disconnect
if ($memcached instanceof \Memcached) {
$memcached->quit();
} else {
$memcached->close();
}
// OK
return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $description);
}
示例2: __destruct
public function __destruct()
{
return $this->_memcached->quit();
}