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


PHP CacheManager::tree方法代碼示例

本文整理匯總了PHP中CacheManager::tree方法的典型用法代碼示例。如果您正苦於以下問題:PHP CacheManager::tree方法的具體用法?PHP CacheManager::tree怎麽用?PHP CacheManager::tree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CacheManager的用法示例。


在下文中一共展示了CacheManager::tree方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTree

 public static function getTree($sid, $URL, $method)
 {
     ///if (!self::$enabled) return;
     if (self::$activeTree) {
         return;
     }
     if (self::$tree != null) {
         return;
     }
     if (strtoupper($method) != 'GET' && !self::$makeTree) {
         return;
     }
     $uTag = md5($URL);
     self::$activeTree = true;
     self::$changedTree = true;
     self::setRoot();
     $uriTag = self::generateETag($URL);
     $list = self::loadData('tree_' . $uTag);
     if ($list === null) {
         self::$changedTree = false;
         ///Logger::Log('no tree', LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
         return;
     } else {
         ///Logger::Log('tree found', LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
     }
     $list = json_decode($list, true);
     $result = self::loadData('data_' . $list[0]['eTag']);
     if ($result === null) {
         self::$changedTree = false;
         ///Logger::Log('no result', LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
         return;
     }
     self::$tree = json_decode(json_encode($list));
     $sources = array();
     $allOK = true;
     foreach ($list as $key => $elem) {
         if ($elem['toSid'] === null) {
             $sources[$key] = $elem;
         }
     }
     // call sources
     if ($allOK) {
         foreach ($sources as $key => $source) {
             $answ = Request::get($source['toURL'], array(), '', true);
             if (!isset($answ['headers']['Etag']) || $answ['headers']['Etag'] != $source['eTag']) {
                 $allOK = false;
                 ///Logger::Log('call '.$source['toURL'].(isset($answ['headers']['Etag']) ? ' is not equal, recvHash: '.$answ['headers']['Etag'] : '').' oldHash: '.$source['eTag'] , LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
             } else {
                 ///Logger::Log('call '.$source['toURL'].' is equal' , LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
             }
         }
     }
     if ($allOK) {
         self::$changedTree = true;
         if (isset($list[0])) {
             self::cacheDataSimple($sid, $list[0]['toName'], $list[0]['toURL'], $result, 200, $list[0]['toMethod']);
             ///Logger::Log('cache hit', LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
         } else {
             ///Logger::Log('nonono', LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
         }
     } else {
         // remove tree
         self::removeData('tree_' . $uTag);
     }
 }
開發者ID:sawh,項目名稱:ostepu-system,代碼行數:65,代碼來源:CacheManager.php


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