tiny optimisation, and fix for handling of _data private member variable
This commit is contained in:
parent
c43d470ac0
commit
160bae1aa3
@ -54,7 +54,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
|
|||||||
/**
|
/**
|
||||||
* @var array $data current cache data array
|
* @var array $data current cache data array
|
||||||
*/
|
*/
|
||||||
protected $_data;
|
protected $_data = array();
|
||||||
/**
|
/**
|
||||||
* @var boolean $success the success of last operation
|
* @var boolean $success the success of last operation
|
||||||
*/
|
*/
|
||||||
@ -294,7 +294,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
|
|||||||
|
|
||||||
$data = false;
|
$data = false;
|
||||||
// only process SELECT statements
|
// only process SELECT statements
|
||||||
if (substr(trim(strtoupper($query)), 0, 6) == 'SELECT') {
|
if (substr(strtoupper(trim($query), 0, 6)) == 'SELECT') {
|
||||||
|
|
||||||
$this->add($query, $event->getInvoker()->getName());
|
$this->add($query, $event->getInvoker()->getName());
|
||||||
|
|
||||||
@ -315,7 +315,10 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
|
|||||||
$this->_driver->save(md5(serialize($query)), $data);
|
$this->_driver->save(md5(serialize($query)), $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($data)
|
||||||
$this->_data = $data;
|
$this->_data = $data;
|
||||||
|
else
|
||||||
|
$this->_data = array();
|
||||||
}
|
}
|
||||||
return (bool) $data;
|
return (bool) $data;
|
||||||
}
|
}
|
||||||
@ -362,7 +365,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
|
|||||||
$data = false;
|
$data = false;
|
||||||
|
|
||||||
// only process SELECT statements
|
// only process SELECT statements
|
||||||
if (substr(trim(strtoupper($query)), 0, 6) == 'SELECT') {
|
if (substr(strtoupper(trim($query), 0, 6)) == 'SELECT') {
|
||||||
|
|
||||||
$this->add($query, $event->getInvoker()->getDbh()->getName());
|
$this->add($query, $event->getInvoker()->getDbh()->getName());
|
||||||
|
|
||||||
@ -386,8 +389,10 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite
|
|||||||
$this->_driver->save(md5(serialize(array($query, $event->getParams()))), $data);
|
$this->_driver->save(md5(serialize(array($query, $event->getParams()))), $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($data)
|
||||||
$this->_data = $data;
|
$this->_data = $data;
|
||||||
|
else
|
||||||
|
$this->_data = array();
|
||||||
|
|
||||||
}
|
}
|
||||||
return (bool) $data;
|
return (bool) $data;
|
||||||
|
Loading…
Reference in New Issue
Block a user