Commit 9703f18c authored by zYne's avatar zYne

--no commit message

--no commit message
parent 2431e481
...@@ -191,6 +191,7 @@ final class Doctrine ...@@ -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,6 +133,12 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -133,6 +133,12 @@ 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();
/** /**
...@@ -199,15 +205,27 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -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);
}
/**
* 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;
} }
/** /**
* setTimeToLive * 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 ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment