当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObject::isCacheExpired方法代码示例

本文整理汇总了PHP中eZContentObject::isCacheExpired方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::isCacheExpired方法的具体用法?PHP eZContentObject::isCacheExpired怎么用?PHP eZContentObject::isCacheExpired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentObject的用法示例。


在下文中一共展示了eZContentObject::isCacheExpired方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gmapStaticImageRetrieve

 public static function gmapStaticImageRetrieve($file, $mtime, $args)
 {
     if (!eZContentObject::isCacheExpired($mtime)) {
         return file_get_contents($file);
     } else {
         $expiryReason = 'Content cache is expired';
         return new eZClusterFileFailure(1, $expiryReason);
     }
 }
开发者ID:OpencontentCoop,项目名称:ocoperatorscollection,代码行数:9,代码来源:ocoperatorscollectionstools.php

示例2: restore

 static function restore($siteDesign, $nodeID, $viewMode, $language, $offset, $roleList, $discountList, $layout, $parameters = array())
 {
     $result = array();
     $cachePathInfo = eZContentCache::cachePathInfo($siteDesign, $nodeID, $viewMode, $language, $offset, $roleList, $discountList, $layout, false, $parameters);
     $cacheDir = $cachePathInfo['dir'];
     $cacheFile = $cachePathInfo['file'];
     $cachePath = $cachePathInfo['path'];
     $timestamp = false;
     $cacheFile = eZClusterFileHandler::instance($cachePath);
     if ($cacheFile->exists()) {
         $timestamp = $cacheFile->mtime();
         if (eZContentObject::isCacheExpired($timestamp)) {
             eZDebugSetting::writeDebug('kernel-content-view-cache', 'cache expired #2');
             return false;
         }
         eZDebugSetting::writeDebug('kernel-content-view-cache', "checking viewmode '{$viewMode}' #1");
         if (eZContentObject::isComplexViewModeCacheExpired($viewMode, $timestamp)) {
             eZDebugSetting::writeDebug('kernel-content-view-cache', "viewmode '{$viewMode}' cache expired #2");
             return false;
         }
     }
     if ($viewMode == 'pdf') {
         return $cachePath;
     }
     eZDebugSetting::writeDebug('kernel-content-view-cache', 'cache used #2');
     $fileName = $cacheDir . "/" . $cacheFile;
     $cacheFile = eZClusterFileHandler::instance($fileName);
     $contents = $cacheFile->fetchContents();
     $cachedArray = unserialize($contents);
     $cacheTTL = $cachedArray['cache_ttl'];
     // Check if cache has expired
     if ($cacheTTL > 0) {
         $expiryTime = $timestamp + $cacheTTL;
         if (time() > $expiryTime) {
             return false;
         }
     }
     // Check for template language timestamp
     $cacheCodeDate = $cachedArray['cache_code_date'];
     if ($cacheCodeDate != self::CODE_DATE) {
         return false;
     }
     $viewMode = $cachedArray['content_info']['viewmode'];
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('node', $nodeID), array('view_offset', $offset), array('viewmode', $viewMode), array('section', $cachedArray['section_id'])));
     $result['content_info'] = $cachedArray['content_info'];
     $result['content'] = $cachedArray['content'];
     $result['view_parameters'] = $cachedArray['content_info']['view_parameters'];
     foreach (array('path', 'node_id', 'section_id', 'navigation_part') as $item) {
         if (isset($cachedArray[$item])) {
             $result[$item] = $cachedArray[$item];
         }
     }
     return $result;
 }
开发者ID:legende91,项目名称:ez,代码行数:55,代码来源:ezcontentcache.php

示例3: contentViewRetrieve

 /**
  * Retrieve content view data
  *
  * @see contentViewGenerate()
  *
  * @param string $file
  * @param int $mtime File modification time
  * @param array $args Hash containing arguments, the used ones are:
  *  - ini
  *
  * @return \eZClusterFileFailure
  */
 public static function contentViewRetrieve($file, $mtime, $args)
 {
     extract($args);
     $cacheExpired = false;
     // Read Cache file
     if (!eZContentObject::isCacheExpired($mtime)) {
         //        $contents = $cacheFile->fetchContents();
         $contents = file_get_contents($file);
         $Result = unserialize($contents);
         if (!is_array($Result)) {
             $expiryReason = 'Unexpected cache file content';
             $cacheExpired = true;
         }
         // Check if a no_cache key has been set in the viewcache, and
         // return an eZClusterFileFailure if it has
         if (isset($Result['no_cache'])) {
             return new eZClusterFileFailure(3, "Cache has been disabled for this node");
         }
         // Check if cache has expired when cache_ttl is set
         $cacheTTL = isset($Result['cache_ttl']) ? $Result['cache_ttl'] : -1;
         if ($cacheTTL > 0) {
             $expiryTime = $mtime + $cacheTTL;
             if (time() > $expiryTime) {
                 $cacheExpired = true;
                 $expiryReason = 'Content cache is expired by cache_ttl=' . $cacheTTL;
             }
         }
         // Check if template source files are newer, but only if the cache is not expired
         if (!$cacheExpired) {
             $developmentModeEnabled = $ini->variable('TemplateSettings', 'DevelopmentMode') == 'enabled';
             // Only do filemtime checking when development mode is enabled.
             if ($developmentModeEnabled && isset($Result['template_list'])) {
                 foreach ($Result['template_list'] as $templateFile) {
                     if (!file_exists($templateFile)) {
                         $cacheExpired = true;
                         $expiryReason = "Content cache is expired by template file '" . $templateFile . "', it does not exist anymore";
                         break;
                     } else {
                         if (filemtime($templateFile) > $mtime) {
                             $cacheExpired = true;
                             $expiryReason = "Content cache is expired by template file '" . $templateFile . "'";
                             break;
                         }
                     }
                 }
             }
         }
         if (!$cacheExpired) {
             if (!isset($Result['content_info'])) {
                 // set error type & number for kernel errors (see https://jira.ez.no/browse/EZP-23046)
                 if (isset($Result['errorType']) && isset($Result['errorNumber'])) {
                     $res = eZTemplateDesignResource::instance();
                     $res->setKeys(array(array('error_type', $Result['errorType']), array('error_number', $Result['errorNumber'])));
                 }
                 return $Result;
             }
             $keyArray = array(array('object', $Result['content_info']['object_id']), array('node', $Result['content_info']['node_id']), array('parent_node', $Result['content_info']['parent_node_id']), array('parent_node_remote_id', $Result['content_info']['parent_node_remote_id']), array('parent_object_remote_id', $Result['content_info']['parent_object_remote_id']), array('class', $Result['content_info']['class_id']), array('view_offset', $Result['content_info']['offset']), array('navigation_part_identifier', $Result['content_info']['navigation_part_identifier']), array('viewmode', $Result['content_info']['viewmode']), array('depth', $Result['content_info']['node_depth']), array('remote_id', $Result['content_info']['remote_id']), array('node_remote_id', $Result['content_info']['node_remote_id']), array('url_alias', $Result['content_info']['url_alias']), array('persistent_variable', $Result['content_info']['persistent_variable']), array('class_group', $Result['content_info']['class_group']), array('parent_class_id', $Result['content_info']['parent_class_id']), array('parent_class_identifier', $Result['content_info']['parent_class_identifier']), array('state', $Result['content_info']['state']), array('state_identifier', $Result['content_info']['state_identifier']), array('section', $Result['section_id']));
             if (isset($Result['content_info']['class_identifier'])) {
                 $keyArray[] = array('class_identifier', $Result['content_info']['class_identifier']);
             }
             $res = eZTemplateDesignResource::instance();
             $res->setKeys($keyArray);
             return $Result;
         }
     } else {
         $expiryReason = 'Content cache is expired by eZContentObject::isCacheExpired(' . $mtime . ")";
     }
     // Cache is expired so return specialized cluster object
     if (!isset($expiryReason)) {
         $expiryReason = 'Content cache is expired';
     }
     return new eZClusterFileFailure(1, $expiryReason);
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:85,代码来源:eznodeviewfunctions.php


注:本文中的eZContentObject::isCacheExpired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。