Skip to content

Commit

Permalink
Add skeletons for QueryCacher & related test.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 4, 2014
1 parent f47e844 commit 86ce95b
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Cake/ORM/QueryCacher.php
@@ -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) {
}

}
87 changes: 87 additions & 0 deletions Cake/Test/TestCase/ORM/QueryCacherTest.php
@@ -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() {
}

}

0 comments on commit 86ce95b

Please sign in to comment.