From: alex <bin...@li...> - 2001-08-09 00:52:53
|
alex Wed Aug 8 17:52:48 2001 EDT Modified files: /r2/binarycloud/base/core Page.php /r2/binarycloud/base/init Init.php /r2/binarycloud/base/mgr CacheManager.php Makefile /r2/binarycloud/user/htdocs mod_cache_test.php Log: Test page... Index: r2/binarycloud/base/core/Page.php diff -u r2/binarycloud/base/core/Page.php:1.14 r2/binarycloud/base/core/Page.php:1.15 --- r2/binarycloud/base/core/Page.php:1.14 Wed Aug 8 16:04:52 2001 +++ r2/binarycloud/base/core/Page.php Wed Aug 8 17:51:54 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: Page.php,v 1.14 2001/08/08 23:04:52 alex Exp $ + * -File $Id: Page.php,v 1.15 2001/08/09 00:51:54 alex Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Authors alex black, en...@tu... @@ -9,6 +9,7 @@ */ $PACKAGE='binarycloud.core'; + // }}} // {{{ Page /** @@ -164,7 +165,7 @@ echo join('', $this->output); } - if ($gPageDef['cache']) { + if (isset($gPageDef['cache'])) { global $CacheManager; $CacheManager->CachePage(); } Index: r2/binarycloud/base/init/Init.php diff -u r2/binarycloud/base/init/Init.php:1.36 r2/binarycloud/base/init/Init.php:1.37 --- r2/binarycloud/base/init/Init.php:1.36 Wed Aug 1 14:47:53 2001 +++ r2/binarycloud/base/init/Init.php Wed Aug 8 17:52:22 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /******************************************************************************* - ** -File $Id: Init.php,v 1.36 2001/08/01 21:47:53 alex Exp $ + ** -File $Id: Init.php,v 1.37 2001/08/09 00:52:22 alex Exp $ ** -License LGPL (http://www.gnu.org/copyleft/lesser.html) ** -Copyright 2001, The Turing Studio, Inc. ** -Author alex black, en...@tu... @@ -69,10 +69,10 @@ $this->_set_include_paths(); $this->_set_ini(); $this->_load_pear(); - $this->_load_cache(); $this->_load_auth(); $this->_load_perm(); $this->_load_page(); + $this->_load_cache(); } // }}} @@ -352,10 +352,13 @@ function _load_cache() { global $gPageDef; - if ($gPageDef['cache']) { + if ($gPageDef['init']['cache']) { import('ext.pear.Cache'); + import('binarycloud.mgr.CacheManager'); global $Cache; + global $CacheManager; $Cache = new Cache("file", array('cache_dir'=>BC_PATH_CACHE)); + $CacheManager = new CacheManager(); return true; } else { return false; @@ -378,14 +381,13 @@ function _load_page() { global $gPageDef; - + if ($gPageDef['modules']) { import('binarycloud.core.Page'); global $Page; $Page = new Page(); return true; } else { - return false; } } Index: r2/binarycloud/base/mgr/CacheManager.php diff -u r2/binarycloud/base/mgr/CacheManager.php:1.1 r2/binarycloud/base/mgr/CacheManager.php:1.2 --- r2/binarycloud/base/mgr/CacheManager.php:1.1 Wed Aug 8 12:26:40 2001 +++ r2/binarycloud/base/mgr/CacheManager.php Wed Aug 8 17:52:37 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: CacheManager.php,v 1.1 2001/08/08 19:26:40 alex Exp $ + * -File $Id: CacheManager.php,v 1.2 2001/08/09 00:52:37 alex Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Author alex black, en...@tu... @@ -10,7 +10,7 @@ $PACKAGE='binarycloud.mgr'; // }}} -// {{{ CacheManager +// {{{ CacheManager extends Page /** * This is the CacheManager class, it * @@ -31,11 +31,8 @@ case 'page': $valid_cache = $this->_CheckPageCache(); break; - case 'module_group': - $valid_cache = $this->_CheckModuleGroupCache(); - break; case 'module': - $valid_cache = $this->_CheckModuleCache(); + $valid_cache = $this->_CheckModuleCache($params); break; } @@ -43,15 +40,19 @@ } // }}} - // {{{ method GetPayload() + // {{{ method CacheOutput() /** * This method * - * @access private + * @access public */ - function GetPayload() { - return $this->payload; + function CachePage() { + global $Cache; + global $Debug; + + $Cache->save($this->page_cache['id'],ob_get_contents(),$this->page_cache['expires'],'page'); + $Debug->CaptureMessage('CacheManager', "Cached page output in ".$this->page_cache['id']); } // }}} @@ -65,18 +66,19 @@ function _CheckPageCache() { global $Cache; global $gPageDef; + global $HTTP_SERVER_VARS; $var_name =& $gPageDef['cache']['var']; $this->page_cache['expires'] =& $gPageDef['cache']['expires']; $this->page_cache['seed'] = $HTTP_SERVER_VARS['REQUEST_URI'].":".$var_name.":".$$var_name; $this->page_cache['id'] = $Cache->generateID($this->page_cache['seed']); - $this->page_cache['is_cached'] = $Cache->isCached($this->page_cache['id'],'pages'); - $this->page_cache['is_expired'] = $Cache->isExpired($this->page_cache['id'],'pages'); + $this->page_cache['is_cached'] = $Cache->isCached($this->page_cache['id'],'page'); + $this->page_cache['is_expired'] = $Cache->isExpired($this->page_cache['id'],'page'); if ($this->page_cache['is_cached'] == true && $this->page_cache['is_expired'] == false) { $this->page_cache['is_valid'] = true; - $this->_SetPayload($Cache->get($this->page_cache['id'],'pages')); + $this->_SetCachePayload($Cache->get($this->page_cache['id'],'page')); return true; } else { $this->page_cache['is_valid'] = false; @@ -84,39 +86,15 @@ } } - // }}} - // {{{ method _CheckModuleGroupCache() - /** - * This method - * - * @access private - */ - - function _CheckModuleGroupCache() { - global $Cache; - } - - // }}} - // {{{ method _CheckModuleCache() - /** - * This method - * - * @access private - */ - - function _CheckModuleCache() { - global $Cache; - } - // }}} - // {{{ method _SetPayload() + // {{{ method _SetCachePayload() /** * This method * * @access private */ - function _SetPayload($payload) { + function _SetCachePayload($payload) { $this->payload = $payload; } Index: r2/binarycloud/base/mgr/Makefile diff -u r2/binarycloud/base/mgr/Makefile:1.4 r2/binarycloud/base/mgr/Makefile:1.5 --- r2/binarycloud/base/mgr/Makefile:1.4 Sat Jul 14 19:03:15 2001 +++ r2/binarycloud/base/mgr/Makefile Wed Aug 8 17:52:37 2001 @@ -1,5 +1,5 @@ # {{{ Header -# -File $Id: Makefile,v 1.4 2001/07/15 02:03:15 alex Exp $ +# -File $Id: Makefile,v 1.5 2001/08/09 00:52:37 alex Exp $ # -License LGPL (http://www.gnu.org/copyleft/lesser.html) # -Copyright 2001, Intacct Corp. # -Author odysseas tsatalos, ody...@ya... @@ -8,6 +8,7 @@ include ../../Makefile.in PACKAGEDFILES= \ + CacheManager.php \ $(EMPTY) all: installcode Index: r2/binarycloud/user/htdocs/mod_cache_test.php diff -u r2/binarycloud/user/htdocs/mod_cache_test.php:1.2 r2/binarycloud/user/htdocs/mod_cache_test.php:1.3 --- r2/binarycloud/user/htdocs/mod_cache_test.php:1.2 Wed Aug 8 11:47:57 2001 +++ r2/binarycloud/user/htdocs/mod_cache_test.php Wed Aug 8 17:52:48 2001 @@ -1,7 +1,7 @@ <?php // {{{ Header /* - * -File $Id: mod_cache_test.php,v 1.2 2001/08/08 18:47:57 alex Exp $ + * -File $Id: mod_cache_test.php,v 1.3 2001/08/09 00:52:48 alex Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Author alex black, en...@tu... @@ -14,12 +14,10 @@ // ripped from /path/to/binarycloud/user/htdocs/index.xml $gPageDef = array( -/* 'cache' => array( 'expires' => '30', 'var' => 'moo' ), -*/ 'title' => "binarycloud page title", 'init' => array( 'ini' => true, @@ -27,6 +25,7 @@ 'perm' => false, 'sess' => true, 'lang' => true, + 'cache' => true, ), 'templates' => array( 'default' => array( @@ -85,10 +84,6 @@ 'load_order' => "2" ), - ), - 'cache' => array( - 'expires' => '30', - 'var' => 'moo', ), ), 'left' => array( |