1
0
mirror of synced 2025-01-18 06:21:40 +03:00

DDC-1588 - Improve ResultCache API. The default cache impl is passed to new query cache profiles automatically now.

This commit is contained in:
Benjamin Eberlei 2012-01-09 08:26:07 +01:00
parent 0014afe746
commit 41ae873048
2 changed files with 15 additions and 4 deletions

View File

@ -316,7 +316,7 @@ abstract class AbstractQuery
$this->_queryCacheProfile = $this->_queryCacheProfile
? $this->_queryCacheProfile->setLifetime($lifetime)
: new QueryCacheProfile($lifetime);
: new QueryCacheProfile($lifetime, null, $this->_em->getConfiguration()->getResultCacheImpl());
return $this;
}
@ -615,7 +615,7 @@ abstract class AbstractQuery
{
$this->_queryCacheProfile = $this->_queryCacheProfile
? $this->_queryCacheProfile->setCacheKey($id)
: new QueryCacheProfile(0, $id);
: new QueryCacheProfile(0, $id, $this->_em->getConfiguration()->getResultCacheImpl());
return $this;
}

View File

@ -2,7 +2,7 @@
namespace Doctrine\Tests\ORM\Query;
require_once __DIR__ . '/../../TestInit.php';
use Doctrine\Common\Cache\ArrayCache;
class QueryTest extends \Doctrine\Tests\OrmTestCase
{
@ -90,4 +90,15 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('baz', $q->getHint('bar'));
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints());
}
}
/**
* @group DDC-1588
*/
public function testQueryDefaultResultCache()
{
$this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache());
$q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a");
$q->useResultCache(true);
$this->assertSame($this->_em->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver());
}
}