summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2007-08-16 12:14:53 +0000
committerxue <>2007-08-16 12:14:53 +0000
commit7776abe89d4dd9dd3df302154208daa9ab0d89b4 (patch)
tree4ef539327604ce2280a2cdb6e33249416e29b802
parent33e533d580e0cf189cb5ace9c649d9f54dc076fc (diff)
added TOutputCache.CacheTime.
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/UI/WebControls/TOutputCache.php48
2 files changed, 41 insertions, 8 deletions
diff --git a/HISTORY b/HISTORY
index 4a8c76fa..710d4c44 100644
--- a/HISTORY
+++ b/HISTORY
@@ -14,6 +14,7 @@ ENH: Ticket#672 - ForceSecureConnection to THttpRequest (Carl)
ENH: Ticket#678 - Improved DateTimeFormatInfo performance (Stever)
ENH: Ticket#681 - TUrlMapping can construct custom URLs now (Qiang)
ENH: Added THead requirement check (Qiang)
+ENH: Added TOutputCache.CacheTime (Qiang)
CHG: Ticket#685 - Slashes and backslashes mixup in PradoBase (Qiang)
CHG: GeSHi is replaced with Text_Highlighter (Christophe)
CHG: Validators will not validate disabled controls (Qiang)
diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php
index cb46b2f5..317d87b8 100644
--- a/framework/Web/UI/WebControls/TOutputCache.php
+++ b/framework/Web/UI/WebControls/TOutputCache.php
@@ -84,6 +84,7 @@ class TOutputCache extends TControl implements INamingContainer
private $_keyPrefix='';
private $_varyBySession=false;
private $_cachePostBack=false;
+ private $_cacheTime=0;
/**
* Returns a value indicating whether body contents are allowed for this control.
@@ -116,11 +117,17 @@ class TOutputCache extends TControl implements INamingContainer
{
$this->_cacheAvailable=true;
$data=$this->_cache->get($this->getCacheKey());
- $param=new TOutputCacheCheckDependencyEventParameter;
- $this->onCheckDependency($param);
- $this->_dataCached=($data!==false && $param->getIsValid());
+ if(is_array($data))
+ {
+ $param=new TOutputCacheCheckDependencyEventParameter;
+ $param->setCacheTime(isset($data[3])?$data[3]:0);
+ $this->onCheckDependency($param);
+ $this->_dataCached=$param->getIsValid();
+ }
+ else
+ $this->_dataCached=false;
if($this->_dataCached)
- list($this->_contents,$this->_state,$this->_actions)=$data;
+ list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data;
}
}
}
@@ -329,6 +336,15 @@ class TOutputCache extends TControl implements INamingContainer
}
/**
+ * @return integer the timestamp of the cached content. This is only valid if the content is being cached.
+ * @since 3.1.1
+ */
+ public function getCacheTime()
+ {
+ return $this->_cacheTime;
+ }
+
+ /**
* Returns the dependency of the data to be cached.
* The default implementation simply returns null, meaning no specific dependency.
* This method may be overriden to associate the data to be cached
@@ -470,7 +486,7 @@ class TOutputCache extends TControl implements INamingContainer
$stack->pop();
$content=$textWriter->flush();
- $data=array($content,$this->_state,$this->_actions);
+ $data=array($content,$this->_state,$this->_actions,time());
$this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency());
$writer->write($content);
}
@@ -492,10 +508,8 @@ class TOutputCache extends TControl implements INamingContainer
*/
class TOutputCacheCheckDependencyEventParameter extends TEventParameter
{
- /**
- * @var boolean whether the dependency remains valid
- */
private $_isValid=true;
+ private $_cacheTime=0;
/**
* @return boolean whether the dependency remains valid. Defaults to true.
@@ -512,6 +526,24 @@ class TOutputCacheCheckDependencyEventParameter extends TEventParameter
{
$this->_isValid=TPropertyValue::ensureBoolean($value);
}
+
+ /**
+ * @return integer the timestamp of the cached result. You may use this to help determine any dependency is changed.
+ * @since 3.1.1
+ */
+ public function getCacheTime()
+ {
+ return $this->_cacheTime;
+ }
+
+ /**
+ * @param integer the timestamp of the cached result. This is used internally.
+ * @since 3.1.1
+ */
+ public function setCacheTime($value)
+ {
+ $this->_cacheTime=TPropertyValue::ensureInteger($value);
+ }
}