Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeletons for QueryCacher & related test.
- Loading branch information
Showing
2 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* PHP Version 5.4 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since CakePHP(tm) v 3.0.0 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
namespace Cake\ORM; | ||
|
||
use Cake\ORM\Query; | ||
|
||
/** | ||
* Handles caching queries and loading results from the cache. | ||
* | ||
* Used by Cake\ORM\Query internally. | ||
* | ||
* @see Cake\ORM\Query::cache() for the public interface. | ||
*/ | ||
class QueryCacher { | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string|Closure $key | ||
* @param string|CacheEngine $config | ||
*/ | ||
public function __construct($key, $config) { | ||
$this->_key = $key; | ||
$this->_config = $config; | ||
} | ||
|
||
/** | ||
* Load the cached results from the cache or run the query. | ||
* | ||
* @param Query $query The query the cache read is for. | ||
* @return ResultSet|null Either the cached results or null. | ||
*/ | ||
public function fetch(Query $query) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* PHP Version 5.4 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since CakePHP(tm) v 3.0.0 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
namespace Cake\Test\TestCase\ORM; | ||
|
||
use Cake\TestSuite\TestCase; | ||
|
||
/** | ||
* Query cacher test | ||
*/ | ||
class QueryCacherTest extends TestCase { | ||
|
||
/** | ||
* Setup method | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
$this->engine = $this->getMock('Cake\Cache\CacheEngine'); | ||
Cache::config('queryCache', $this->engine); | ||
} | ||
|
||
/** | ||
* Teardown method | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown() { | ||
parent::tearDown(); | ||
Cache::drop('queryCache'); | ||
} | ||
|
||
/** | ||
* Test fetching with a function to generate the key. | ||
* | ||
* @return void | ||
*/ | ||
public function testFetchFunctionKey() { | ||
} | ||
|
||
/** | ||
* Test fetching with a function to generate the key but the function is poop. | ||
* | ||
* @return void | ||
*/ | ||
public function testFetchFunctionKeyNoString() { | ||
} | ||
|
||
/** | ||
* Test fetching with a cache instance. | ||
* | ||
* @return void | ||
*/ | ||
public function testFetchCacheInstance() { | ||
} | ||
|
||
/** | ||
* Test fetching with a cache hit. | ||
* | ||
* @return void | ||
*/ | ||
public function testFetchCacheHit() { | ||
} | ||
|
||
/** | ||
* Test fetching with a cache miss. | ||
* | ||
* @return void | ||
*/ | ||
public function testFetchCacheMiss() { | ||
} | ||
|
||
} |