diff --git a/lib/Doctrine/Cache.php b/lib/Doctrine/Cache.php index 487435a5b..2479e3fe0 100644 --- a/lib/Doctrine/Cache.php +++ b/lib/Doctrine/Cache.php @@ -39,6 +39,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite 'lifeTime' => 3600, 'statsSlamDefense' => 0.75, 'saveSlamDefense' => 0.80, + 'cleanPropability' => 0.98, 'statsFile' => '../data/stats.cache', ); /** @@ -53,6 +54,10 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite * @var array $data current cache data array */ protected $_data; + /** + * @var boolean $success the success of last operation + */ + protected $_success = false; /** * constructor * @@ -194,6 +199,13 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite { return new ArrayIterator($this->_queries); } + /** + * @return boolean whether or not the last cache operation was successful + */ + public function isSuccessful() + { + return $this->_success; + } /** * save * @@ -265,6 +277,8 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite $data = $this->_driver->fetch(md5($query)); + $this->success = ($data) ? true : false; + $this->_data = $data; return true; @@ -316,9 +330,11 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite if (substr(trim(strtoupper($query)), 0, 6) == 'SELECT') { $this->add($query, $event->getInvoker()->getDbh()->getName()); - + $data = $this->_driver->fetch(md5(serialize(array($query, $event->getParams())))); + $this->success = ($data) ? true : false; + $this->_data = $data; return true; @@ -326,6 +342,15 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite return false; } + /** + * onExecute + * listens the onExecute event of Doctrine_Db_Statement + * + * adds the issued query to internal query stack + * and checks if cached element exists + * + * @return boolean + */ /** * destructor *