This commit is contained in:
parent
2431e48117
commit
9703f18ca8
@ -191,6 +191,7 @@ final class Doctrine
|
|||||||
const ATTR_NS_GAP_DECREASE_EXP = 132;
|
const ATTR_NS_GAP_DECREASE_EXP = 132;
|
||||||
|
|
||||||
const ATTR_CACHE = 150;
|
const ATTR_CACHE = 150;
|
||||||
|
const ATTR_CACHE_LIFESPAN = 151;
|
||||||
const ATTR_LOAD_REFERENCES = 153;
|
const ATTR_LOAD_REFERENCES = 153;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,8 +133,14 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_cache;
|
protected $_cache;
|
||||||
|
/**
|
||||||
|
* @var boolean $_expireCache a boolean value that indicates whether or not to force cache expiration
|
||||||
|
*/
|
||||||
|
protected $_expireCache = false;
|
||||||
|
|
||||||
|
protected $_timeToLive;
|
||||||
|
|
||||||
protected $_tableAliases = array();
|
protected $_tableAliases = array();
|
||||||
/**
|
/**
|
||||||
* @var array $_tableAliasSeeds A simple array keys representing table aliases and values
|
* @var array $_tableAliasSeeds A simple array keys representing table aliases and values
|
||||||
* as table alias seeds. The seeds are used for generating short table
|
* as table alias seeds. The seeds are used for generating short table
|
||||||
@ -199,15 +205,27 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
}
|
}
|
||||||
$this->_cache = $driver;
|
$this->_cache = $driver;
|
||||||
|
|
||||||
return $this->setTimeToLive($timeToLive);
|
return $this->setCacheLifeSpan($timeToLive);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* setTimeToLive
|
* expireCache
|
||||||
|
*
|
||||||
|
* @param boolean $expire whether or not to force cache expiration
|
||||||
|
* @return Doctrine_Hydrate this object
|
||||||
|
*/
|
||||||
|
public function expireCache($expire = true)
|
||||||
|
{
|
||||||
|
$this->_expireCache = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* setCacheLifeSpan
|
||||||
*
|
*
|
||||||
* @param integer $timeToLive how long the cache entry is valid
|
* @param integer $timeToLive how long the cache entry is valid
|
||||||
* @return Doctrine_Hydrate this object
|
* @return Doctrine_Hydrate this object
|
||||||
*/
|
*/
|
||||||
public function setTimeToLive($timeToLive)
|
public function setCacheLifeSpan($timeToLive)
|
||||||
{
|
{
|
||||||
if ($timeToLive !== null) {
|
if ($timeToLive !== null) {
|
||||||
$timeToLive = (int) $timeToLive;
|
$timeToLive = (int) $timeToLive;
|
||||||
@ -745,7 +763,8 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
// calculate hash for dql query
|
// calculate hash for dql query
|
||||||
$hash = md5($dql . var_export($params, true));
|
$hash = md5($dql . var_export($params, true));
|
||||||
|
|
||||||
$cached = $cacheDriver->fetch($hash);
|
$cached = ($this->_expireCache) ? null : $cacheDriver->fetch($hash);
|
||||||
|
|
||||||
|
|
||||||
if ($cached === null) {
|
if ($cached === null) {
|
||||||
// cache miss
|
// cache miss
|
||||||
|
Loading…
x
Reference in New Issue
Block a user