summaryrefslogtreecommitdiff
path: root/framework/Data/SqlMap
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/SqlMap')
-rw-r--r--framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php9
-rw-r--r--framework/Data/SqlMap/TSqlMapConfig.php7
-rw-r--r--framework/Data/SqlMap/TSqlMapManager.php14
3 files changed, 28 insertions, 2 deletions
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.
@@ -113,6 +115,18 @@ class TSqlMapManager extends TComponent
}
/**
+ * @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()}.
* @return TSqlMapGateway create and configure a new TSqlMapGateway.