| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/filter_chain/src/lmbInterceptingFilter.interface.php'); 10 lmb_require('limb/web_cache/src/lmbFullPageCacheRuleset.class.php'); 11 lmb_require('limb/web_cache/src/lmbFullPageCache.class.php'); 12 lmb_require('limb/web_cache/src/lmbFullPageCacheRequest.class.php'); 13 lmb_require('limb/web_cache/src/lmbFullPageCacheUser.class.php'); 14 lmb_require('limb/web_cache/src/lmbFullPageCacheWriter.class.php'); 15 lmb_require('limb/web_cache/src/lmbFullPageCacheIniPolicyLoader.class.php'); 16 17 /** 18 * class lmbFullPageCacheFilter. 19 * 20 * @package web_cache 21 * @version $Id: lmbFullPageCacheFilter.class.php 5945 2007-06-06 08:31:43Z pachanga $ 22 */ 23 class lmbFullPageCacheFilter implements lmbInterceptingFilter 24 { 25 protected $user; 26 protected $cache; 27 protected $cache_dir; 28 protected $rules_ini; 29 30 function __construct($rules_ini = 'full_page_cache.ini', $cache_dir = null, $user = null) 31 { 32 $this->rules_ini = $rules_ini; 33 34 if(!$cache_dir) 35 $this->cache_dir = LIMB_VAR_DIR . '/fpcache/'; 36 else 37 $this->cache_dir = $cache_dir; 38 39 if(!is_object($user)) 40 $this->user = new lmbFullPageCacheUser(); 41 else 42 $this->user = $user; 43 } 44 45 function run($filter_chain) 46 { 47 $toolkit = lmbToolkit :: instance(); 48 $request = $toolkit->getRequest(); 49 50 $this->cache = new lmbFullPageCache($this->_createCacheWriter(), 51 $this->_createCachePolicy()); 52 53 $cache_request = new lmbFullPageCacheRequest($request, $this->user); 54 if(!$this->cache->openSession($cache_request)) 55 { 56 $filter_chain->next(); 57 return; 58 } 59 60 $response = $toolkit->getResponse(); 61 if($content = $this->cache->get()) 62 { 63 $response->write($content); 64 } 65 else 66 { 67 $filter_chain->next(); 68 $content = $response->getResponseString(); 69 $this->cache->save($content); 70 } 71 } 72 73 protected function _createCachePolicy() 74 { 75 $loader = new lmbFullPageCacheIniPolicyLoader($this->rules_ini); 76 return $loader->load(); 77 } 78 79 protected function _createCacheWriter() 80 { 81 $writer = new lmbFullPageCacheWriter($this->cache_dir); 82 return $writer; 83 } 84 } 85 86 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Dec 1 03:56:46 2008 | Cross-referenced by PHPXref 0.7 |