From 362aea9c8764437119d09eb6343851db4298a035 Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Sat, 23 May 2009 07:52:15 +0000 Subject: Fixed Issue#161 - SqlMap add cache dependencies if TApplicationMode Debug/Normal --- .../Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php | 9 +++++++++ framework/Data/SqlMap/TSqlMapConfig.php | 7 +++++-- framework/Data/SqlMap/TSqlMapManager.php | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'framework/Data/SqlMap') diff --git a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php index 5854b21a..462b356f 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php @@ -349,6 +349,15 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder $document = $this->loadXmlDocument($filename,$this->_xmlConfig); $this->_document=$document; + static $bCacheDependencies; + if($bCacheDependencies === null) + $bCacheDependencies = Prado::getApplication()->getMode() !== TApplicationMode::Performance; + + if($bCacheDependencies) + $this->_manager->getCacheDependencies() + ->getDependencies() + ->add(new TFileCacheDependency($filename)); + foreach($document->xpath('//resultMap') as $node) $this->loadResultMap($node); diff --git a/framework/Data/SqlMap/TSqlMapConfig.php b/framework/Data/SqlMap/TSqlMapConfig.php index cdf6b541..c57ab40e 100644 --- a/framework/Data/SqlMap/TSqlMapConfig.php +++ b/framework/Data/SqlMap/TSqlMapConfig.php @@ -49,7 +49,7 @@ class TSqlMapConfig extends TDataSourceConfig $cache = $this->getApplication()->getCache(); if($cache !== null) { $cache->delete($this->getCacheKey()); - } + } } /** @@ -62,7 +62,10 @@ class TSqlMapConfig extends TDataSourceConfig { $cache = $this->getApplication()->getCache(); if($cache !== null) { - return $cache->set($this->getCacheKey(), $manager); + $dependencies = null; + if($this->getApplication()->getMode() !== TApplicationMode::Performance) + $dependencies = $manager->getCacheDependencies(); + return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); } } return false; diff --git a/framework/Data/SqlMap/TSqlMapManager.php b/framework/Data/SqlMap/TSqlMapManager.php index 290050d1..432c1c5e 100644 --- a/framework/Data/SqlMap/TSqlMapManager.php +++ b/framework/Data/SqlMap/TSqlMapManager.php @@ -18,6 +18,7 @@ Prado::using('System.Data.SqlMap.Configuration.TSqlMapStatement'); Prado::using('System.Data.SqlMap.Configuration.*'); Prado::using('System.Data.SqlMap.DataMapper.*'); Prado::using('System.Data.SqlMap.Statements.*'); +Prado::using('System.Caching.TCache'); /** @@ -50,6 +51,7 @@ class TSqlMapManager extends TComponent private $_connection; private $_gateway; + private $_cacheDependencies; /** * Constructor, create a new SqlMap manager. @@ -112,6 +114,18 @@ class TSqlMapManager extends TComponent $config->configure($file); } + /** + * @return TChainedCacheDependency + * @since 3.1.5 + */ + public function getCacheDependencies() + { + if($this->_cacheDependencies === null) + $this->_cacheDependencies=new TChainedCacheDependency(); + + return $this->_cacheDependencies; + } + /** * Configures the current TSqlMapManager using the given xml configuration file * defined in {@link ConfigFile setConfigFile()}. -- cgit v1.2.3