summaryrefslogtreecommitdiff
path: root/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php')
-rw-r--r--framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
index ba8c3d0c..ce122f6a 100644
--- a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
+++ b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
@@ -697,6 +697,8 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
}
$cache = Prado::createComponent($cacheModel->getImplementationClass());
$this->setObjectPropFromNode($cache,$node,$properties);
+ $this->loadFlushInterval($cacheModel,$node);
+
$cacheModel->initialize($cache);
$this->_manager->addCacheModel($cacheModel);
foreach($node->xpath('flushOnExecute') as $flush)
@@ -704,6 +706,40 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
}
/**
+ * Load the flush interval
+ * @param TSqlMapCacheModel cache model
+ * @param SimpleXmlElement cache node
+ */
+ protected function loadFlushInterval($cacheModel, $node)
+ {
+ $flushInterval = $node->xpath('flushInterval');
+ if($flushInterval === null || count($flushInterval) === 0) return;
+ $duration = 0;
+ foreach($flushInterval[0]->attributes() as $name=>$value)
+ {
+ switch(strToLower($name))
+ {
+ case 'seconds':
+ $duration += (integer)$value;
+ break;
+ case 'minutes':
+ $duration += 60 * (integer)$value;
+ break;
+ case 'hours':
+ $duration += 3600 * (integer)$value;
+ break;
+ case 'days':
+ $duration += 86400 * (integer)$value;
+ break;
+ case 'duration':
+ $duration = (integer)$value;
+ break 2; // switch, foreach
+ }
+ }
+ $cacheModel->setFlushInterval($duration);
+ }
+
+ /**
* Load the flush on cache properties.
* @param TSqlMapCacheModel cache model
* @param SimpleXmlElement parent node.