Changeset 1467
- Timestamp:
- 03/15/10 04:55:38 (5 months ago)
- Files:
-
- trunk/lib/AkActionController/AkCacheHandler.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/AkActionController/AkCacheHandler.php
r1466 r1467 521 521 function cachePage($content, $path = null, $language = null, $gzipped=false, $sendETag = false, $orgStrlen = null) 522 522 { 523 global $_ENV; 523 524 static $ETag; 524 525 … … 562 563 $cacheTimestamp = time(); 563 564 $content = $this->_modifyCacheContent($content,$addHeaders, $removeHeaders,$cacheIds,$cacheGroup); 564 $filename = $this->_storePageCache($content,$cacheId,$cacheGroup); 565 $res = $this->_cache_store->save($filename,$cacheId,$cacheGroup); 565 //Ak::getLogger('caching')->message('Got timestamp from ENV:'.$_ENV['_page_cache_timestamp']); 566 $cached_params = $this->_storePageCache($content,$cacheId,$cacheGroup,!empty($_ENV['_page_cache_timestamp'])?$_ENV['_page_cache_timestamp']:null); 567 $res = $this->_cache_store->save($cached_params,$cacheId,$cacheGroup); 566 568 if ($notNormalizedCacheId != $cacheId) { 567 569 // Store the not normalized cacheid 568 $ filename= $this->_storePageCache($content,$cacheId,$cacheGroup);569 $this->_cache_store->save($ filename,$notNormalizedCacheId,$cacheGroup);570 $cached_params = $this->_storePageCache($content,$cacheId,$cacheGroup); 571 $this->_cache_store->save($cached_params,$notNormalizedCacheId,$cacheGroup); 570 572 } 571 573 return $res; 572 574 573 575 } 574 function _storePageCache($content, $cacheId,$cacheGroup )576 function _storePageCache($content, $cacheId,$cacheGroup, $timestamp = null) 575 577 { 576 578 $filename = AK_TMP_DIR.DS.'cache'.DS.$cacheGroup.DS.$cacheId.'.php'; … … 584 586 } 585 587 file_put_contents($filename, $content); 586 587 return $filename; 588 if($timestamp == null) { 589 $timestamp=time(); 590 } 591 touch($filename,$timestamp); 592 return array($filename,$timestamp); 588 593 } 589 594 function _stripCacheSkipSections($content) … … 959 964 function &getCachedPage($path = null,$forcedLanguage = null) 960 965 { 966 global $_ENV; 961 967 $false = false; 962 968 if (!$this->_cachingAllowed()) { … … 974 980 } 975 981 $cacheGroup = $this->_buildCacheGroup(); 976 $cache = $this->_cache_store->get($cacheId, $cacheGroup); 977 978 if (file_exists($cache)) { 982 $cached_params = $this->_cache_store->get($cacheId, $cacheGroup); 983 $timestamp=false; 984 if(is_array($cached_params)) { 985 $cache = $cached_params[0]; 986 $timestamp = $cached_params[1]; 987 } else { 988 $cache = $cached_params; 989 } 990 //Ak::getLogger('caching')->message(var_export($cached_params,true).'mtime:'.filemtime($cache)); 991 if (file_exists($cache) && ($timestamp!==false && filemtime($cache)==$timestamp)) { 979 992 if(!empty($_SESSION)) { 980 993 /** … … 985 998 return $cache; 986 999 } else { 987 1000 if($timestamp!==false) { 1001 /** 1002 * storing timestamp for later cache saving 1003 */ 1004 $_ENV['_page_cache_timestamp'] = $timestamp; 1005 } 988 1006 return $false; 989 1007 }
