From c8919fa9fc845ab7f3c6701b6de08c8cd042ec30 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 15 Jun 2006 14:03:28 +0000 Subject: Added TCache.PrimaryCache property. Added TOutputCache.CacheModuleID property. --- framework/Web/UI/WebControls/TOutputCache.php | 38 +++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php index 76d74b47..b1a7fa93 100644 --- a/framework/Web/UI/WebControls/TOutputCache.php +++ b/framework/Web/UI/WebControls/TOutputCache.php @@ -63,6 +63,7 @@ class TOutputCache extends TControl implements INamingContainer { const CACHE_ID_PREFIX='prado:outputcache'; + private $_cacheModuleID=''; private $_dataCached=false; private $_cacheAvailable=false; private $_cacheChecked=false; @@ -92,12 +93,23 @@ class TOutputCache extends TControl implements INamingContainer if(!$this->_cacheChecked) { $this->_cacheChecked=true; - if(!$this->getPage()->getIsPostBack() && ($this->_cache=$this->getApplication()->getCache())!==null && $this->_duration>0) + if(!$this->getPage()->getIsPostBack() && $this->_duration>0) { - $this->_cacheAvailable=true; - $data=$this->_cache->get($this->getCacheKey()); - if(($this->_dataCached=($data!==false))) - list($this->_contents,$this->_state,$this->_actions)=$data; + if($this->_cacheModuleID!=='') + { + $this->_cache=$this->getApplication()->getModule($this->_cacheModuleID); + if(!($this->_cache instanceof ICache)) + throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID); + } + else + $this->_cache=$this->getApplication()->getCache(); + if($this->_cache!==null) + { + $this->_cacheAvailable=true; + $data=$this->_cache->get($this->getCacheKey()); + if(($this->_dataCached=($data!==false))) + list($this->_contents,$this->_state,$this->_actions)=$data; + } } } } @@ -271,6 +283,22 @@ class TOutputCache extends TControl implements INamingContainer return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID(); } + /** + * @return string the ID of the cache module. Defaults to '', meaning the primary cache module is used. + */ + public function getCacheModuleID() + { + return $this->_cacheModuleID; + } + + /** + * @param string the ID of the cache module. If empty, the primary cache module will be used. + */ + public function setCacheModuleID($value) + { + $this->_cacheModuleID=$value; + } + /** * Sets the prefix of the cache key. * This method is used internally by {@link TTemplate}. -- cgit v1.2.3