當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Memcache::quit方法代碼示例

本文整理匯總了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);
 }
開發者ID:jyxo,項目名稱:php,代碼行數:66,代碼來源:Memcached.php

示例2: __destruct

 public function __destruct()
 {
     return $this->_memcached->quit();
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:4,代碼來源:Memcached.php


注:本文中的Memcache::quit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。