diff options
| author | godzilla80@gmx.net <> | 2009-04-05 16:11:22 +0000 | 
|---|---|---|
| committer | godzilla80@gmx.net <> | 2009-04-05 16:11:22 +0000 | 
| commit | bd2d05119734a7892485cfe3c7bc62a4a606ce6d (patch) | |
| tree | 5f859f4273a51e7f3c0ed5f6b68eef284090aea1 | |
| parent | 9cb370b04651c559391e475db3696c99e7be2dcd (diff) | |
TSqlMapCacheModel now consider <flushInterval> tag as described in doc (sqlmap.pdf) - valid attributes are duration in sec or seconds, minutes, hours, days
| -rw-r--r-- | HISTORY | 1 | ||||
| -rw-r--r-- | framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php | 22 | ||||
| -rw-r--r-- | framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php | 36 | 
3 files changed, 57 insertions, 2 deletions
| @@ -1,5 +1,6 @@  Version 3.1.5 (to be released)  BUG: URL wildcard patterns didn't work with subfolders +BUG/ENH: TSqlMapCacheModel now consider <flushInterval> tag as described in doc (sqlmap.pdf) - valid attributes are duration in sec or seconds, minutes, hours, days (Yves)  BUG: Issue#88 - SQLMap $Param$ re-evaluation bug (Yves)  BUG: Issue#120 - TActiveDropDownList PromptText and PromptValue got lost during callback and data rebind (Yves)  BUG: Issue#68 - TSqlMapConfig::createSqlMapGateway(): assign current connection to cached TSqlMapManager to avoid loosing active transaction (Yves) diff --git a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php index 5d19a3a3..aa688b05 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php @@ -38,8 +38,9 @@ class TSqlMapCacheModel extends TComponent  	private $_hits = 0;
  	private $_requests = 0;
  	private $_id;
 -	private $_implementation='basic';
 +	private $_implementation=TSqlMapCacheTypes::Basic;
  	private $_properties = array();
 +	private $_flushInterval = 0;
  	/**
  	 * @return string unique cache model identifier.
 @@ -74,6 +75,23 @@ class TSqlMapCacheModel extends TComponent  	}
  	/**
 +	 * integer the number of seconds in which the cached value will expire. 0 means never expire.
 +	 * @param int cache size.
 +	 */
 +	public function setFlushInterval($value)
 +	{
 +		$this->_flushInterval=TPropertyValue::ensureInteger($value);
 +	}
 +
 +	/**
 +	 * @return int cache duration.
 +	 */
 +	public function getFlushInterval()
 +	{
 +		return $this->_flushInterval;
 +	}
 +
 +	/**
  	 * Initialize the cache implementation, sets the actual cache contain if supplied.
  	 * @param ISqLMapCache cache implementation instance.
  	 */
 @@ -142,7 +160,7 @@ class TSqlMapCacheModel extends TComponent  			$key = $key->getHash();
  		if($value!==null)
 -			$this->_cache->set($key, $value);
 +			$this->_cache->set($key, $value, $this->_flushInterval);
  	}
  	/**
 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.
 | 
