CCacheDependency
CCacheDependency is the base class for cache dependency classes.
CCacheDependency implements the
ICacheDependency interface. Child classes should override its
generateDependentData for actual dependency checking.
Public Properties
Property |
Type |
Description |
Defined By |
dependentData | mixed | the data used to determine if dependency has been changed. | CCacheDependency |
hasChanged | boolean | whether the dependency has changed. | CCacheDependency |
reuseDependentData | boolean | Whether this dependency is reusable or not. | CCacheDependency |
Protected Methods
Method |
Description |
Defined By |
generateDependentData() | Generates the data needed to determine if dependency has been changed. | CCacheDependency |
Property Details
public mixed getDependentData()
the data used to determine if dependency has been changed. This data is available after evaluateDependency is called.
public boolean getHasChanged()
whether the dependency has changed.
public boolean $reuseDependentData;
Whether this dependency is reusable or not. If set to true, dependent data for this cache dependency will only be generated once per request. You can then use the same cache dependency for multiple separate cache calls on the same page without the overhead of re-evaluating the dependency each time. Defaults to false;
Method Details
public void evaluateDependency() |
Source Code: framework/caching/dependencies/CCacheDependency.php#51 (
show)
public function evaluateDependency()
{
if ($this->reuseDependentData)
{
$hash=$this->getHash();
if(!isset(self::$_reusableData[$hash]['dependentData']))
self::$_reusableData[$hash]['dependentData']=$this->generateDependentData();
$this->_data=self::$_reusableData[$hash]['dependentData'];
}
else
$this->_data=$this->generateDependentData();
}
Evaluates the dependency by generating and saving the data related with dependency. This method is invoked by cache before writing data into it.
protected mixed generateDependentData() |
{return} | mixed | the data needed to determine if dependency has been changed. |
Generates the data needed to determine if dependency has been changed. Derived classes should override this method to generate actual dependent data.
public mixed getDependentData() |
{return} | mixed | the data used to determine if dependency has been changed. This data is available after evaluateDependency is called. |
public boolean getHasChanged() |
{return} | boolean | whether the dependency has changed. |
Source Code: framework/caching/dependencies/CCacheDependency.php#67 (
show)
public function getHasChanged()
{
if ($this->reuseDependentData)
{
$hash=$this->getHash();
if(!isset(self::$_reusableData[$hash]['dependentData']))
self::$_reusableData[$hash]['dependentData']=$this->generateDependentData();
return self::$_reusableData[$hash]['dependentData']!=$this->_data;
}
else
return $this->generateDependentData()!=$this->_data;
}
public static void resetReusableData() |
Resets cached data for reusable dependencies.