mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #8663 from chinpei215/2.next-query-cache
2.next Add DboSource::flushQueryCache()
This commit is contained in:
commit
b71e93a16e
2 changed files with 25 additions and 0 deletions
|
@ -3540,6 +3540,15 @@ class DboSource extends DataSource {
|
|||
return 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Empties the query caches.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flushQueryCache() {
|
||||
$this->_queryCache = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a new key for the in memory sql query cache
|
||||
*
|
||||
|
|
|
@ -1810,4 +1810,20 @@ class DboSourceTest extends CakeTestCase {
|
|||
$User->Article = $Article;
|
||||
$User->find('first', array('conditions' => array('User.id' => 1), 'recursive' => 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that flushQueryCache works as expected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFlushQueryCache() {
|
||||
$this->db->flushQueryCache();
|
||||
$this->db->query('SELECT 1');
|
||||
$this->db->query('SELECT 1');
|
||||
$this->db->query('SELECT 2');
|
||||
$this->assertAttributeCount(2, '_queryCache', $this->db);
|
||||
|
||||
$this->db->flushQueryCache();
|
||||
$this->assertAttributeCount(0, '_queryCache', $this->db);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue