From: alex <bin...@li...> - 2001-08-08 19:26:46
|
alex Wed Aug 8 12:26:40 2001 EDT Added files: /r2/binarycloud/base/mgr CacheManager.php Log: This is the CacheManager, which contains code moved out from page (and some new stuff) for managing caches of page output, module group output, and module output. This is not for generalized caching, for that you can use the pear cache class. Index: r2/binarycloud/base/mgr/CacheManager.php +++ r2/binarycloud/base/mgr/CacheManager.php <?php // Header {{{ /* * -File $Id: CacheManager.php,v 1.1 2001/08/08 19:26:40 alex Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Author alex black, en...@tu... */ $PACKAGE='binarycloud.mgr'; // }}} // {{{ CacheManager /** * This is the CacheManager class, it * */ class CacheManager { // {{{ method CheckCache() /** * This method * * @access public */ function CheckCache($type) { $valid_cache = false; switch ($type) { case 'page': $valid_cache = $this->_CheckPageCache(); break; case 'module_group': $valid_cache = $this->_CheckModuleGroupCache(); break; case 'module': $valid_cache = $this->_CheckModuleCache(); break; } return $valid_cache; } // }}} // {{{ method GetPayload() /** * This method * * @access private */ function GetPayload() { return $this->payload; } // }}} // {{{ method _CheckPageCache() /** * This method * * @access private */ function _CheckPageCache() { global $Cache; global $gPageDef; $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'); 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')); return true; } else { $this->page_cache['is_valid'] = false; return false; } } // }}} // {{{ method _CheckModuleGroupCache() /** * This method * * @access private */ function _CheckModuleGroupCache() { global $Cache; } // }}} // {{{ method _CheckModuleCache() /** * This method * * @access private */ function _CheckModuleCache() { global $Cache; } // }}} // {{{ method _SetPayload() /** * This method * * @access private */ function _SetPayload($payload) { $this->payload = $payload; } // }}} // {{{ Vars var $page_cache; var $payload; // }}} } // }}} ?> |
From: alex <bin...@li...> - 2001-08-16 20:44:03
|
alex Thu Aug 16 13:43:57 2001 EDT Modified files: /r2/binarycloud/base/mgr CacheManager.php Log: Many bugfixes, some reorganization. Now properly functions in conjunction with Page to cache Module output. Index: r2/binarycloud/base/mgr/CacheManager.php diff -u r2/binarycloud/base/mgr/CacheManager.php:1.4 r2/binarycloud/base/mgr/CacheManager.php:1.5 --- r2/binarycloud/base/mgr/CacheManager.php:1.4 Thu Aug 16 10:08:24 2001 +++ r2/binarycloud/base/mgr/CacheManager.php Thu Aug 16 13:43:57 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: CacheManager.php,v 1.4 2001/08/16 17:08:24 alex Exp $ + * -File $Id: CacheManager.php,v 1.5 2001/08/16 20:43:57 alex Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Author alex black, en...@tu... @@ -26,9 +26,19 @@ function CacheOutput($output, $group) { global $Cache; global $Debug; - - $Cache->save($this->page['id'],$output,$this->page['expires'],$group); - $Debug->CaptureMessage('CacheManager', "Cached $group output in ".$this->page['id']); + global $CacheManager; + switch ($group) { + case 'page': + $id =& $this->page['id']; + $expires =& $this->page['expires']; + break; + case 'module': + $id =& $this->module['id']; + $expires =& $this->module['expires']; + break; + } + $Cache->save($id,$output,$expires,$group); + $Debug->CaptureMessage('CacheManager', "Cached $group output in ".$id); } // }}} @@ -54,7 +64,6 @@ function GetModuleCache() { global $Cache; - echo "returning mod cache"; return $Cache->get($this->module['id'],'module'); } @@ -74,12 +83,14 @@ switch ($type) { case 'page': $this->page['seed'] = $HTTP_SERVER_VARS['REQUEST_URI']; - if ($gPageDef['cache']['var']) { + if (isset($gPageDef['cache']['var'])) { $var_name =& $gPageDef['cache']['var']; $this->page['seed'] .= ":".$var_name.":".$$var_name; } $this->page['id'] = $Cache->generateID($this->page['seed']); - $this->page['expires'] =& $gPageDef['cache']['expires']; + if (isset($gPageDef['cache']['expires'])) { + $this->page['expires'] =& $gPageDef['cache']['expires']; + } $this->page['is_cached'] = $Cache->isCached($this->page['id'],$type); $this->page['is_expired'] = $Cache->isExpired($this->page['id'],$type); if ($this->page['is_cached'] == true && $this->page['is_expired'] == false) { @@ -99,7 +110,7 @@ $this->module['seed'] .= $HTTP_SERVER_VARS['REQUEST_URI']; } $this->module['id'] = $Cache->generateID($this->module['seed']); - $this->module['expires'] =& $gPageDef['cache']['expires']; + $this->module['expires'] =& $mod['cache']['expires']; $this->module['is_cached'] = $Cache->isCached($this->module['id'],$type); $this->module['is_expired'] = $Cache->isExpired($this->module['id'],$type); if ($this->module['is_cached'] == true && $this->module['is_expired'] == false) { @@ -121,4 +132,4 @@ // }}} } // }}} -?> +?> \ No newline at end of file |