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/Caching/TCache.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'framework/Caching/TCache.php') diff --git a/framework/Caching/TCache.php b/framework/Caching/TCache.php index e369f1df..b1d53525 100644 --- a/framework/Caching/TCache.php +++ b/framework/Caching/TCache.php @@ -44,18 +44,44 @@ abstract class TCache extends TModule implements ICache { private $_prefix=null; + private $_primary=true; /** * Initializes the cache module. * This method initializes the cache key prefix and registers the cache module - * with the application. + * with the application if the cache is primary. * @param TXmlElement the module configuration */ public function init($config) { if($this->_prefix===null) $this->_prefix=$this->getApplication()->getUniqueID(); - $this->getApplication()->setCache($this); + if($this->_primary) + { + if($this->getApplication()->getCache()===null) + $this->getApplication()->setCache($this); + else + throw new TConfigurationException('cache_primary_duplicated',get_class($this)); + } + } + + /** + * @return boolean whether this cache module is used as primary/system cache. + * A primary cache is used by PRADO core framework to cache data such as + * parsed templates, themes, etc. + */ + public function getPrimaryCache() + { + return $this->_primary; + } + + /** + * @param boolean whether this cache module is used as primary/system cache. Defaults to false. + * @see getPrimaryCache + */ + public function setPrimaryCache($value) + { + $this->_primary=TPropertyValue::ensureBoolean($value); } /** -- cgit v1.2.3