DDC-1588 - Improve ResultCache API. The default cache impl is passed to new query cache profiles automatically now.
This commit is contained in:
parent
0014afe746
commit
41ae873048
@ -316,7 +316,7 @@ abstract class AbstractQuery
|
|||||||
|
|
||||||
$this->_queryCacheProfile = $this->_queryCacheProfile
|
$this->_queryCacheProfile = $this->_queryCacheProfile
|
||||||
? $this->_queryCacheProfile->setLifetime($lifetime)
|
? $this->_queryCacheProfile->setLifetime($lifetime)
|
||||||
: new QueryCacheProfile($lifetime);
|
: new QueryCacheProfile($lifetime, null, $this->_em->getConfiguration()->getResultCacheImpl());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ abstract class AbstractQuery
|
|||||||
{
|
{
|
||||||
$this->_queryCacheProfile = $this->_queryCacheProfile
|
$this->_queryCacheProfile = $this->_queryCacheProfile
|
||||||
? $this->_queryCacheProfile->setCacheKey($id)
|
? $this->_queryCacheProfile->setCacheKey($id)
|
||||||
: new QueryCacheProfile(0, $id);
|
: new QueryCacheProfile(0, $id, $this->_em->getConfiguration()->getResultCacheImpl());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Query;
|
namespace Doctrine\Tests\ORM\Query;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../TestInit.php';
|
use Doctrine\Common\Cache\ArrayCache;
|
||||||
|
|
||||||
class QueryTest extends \Doctrine\Tests\OrmTestCase
|
class QueryTest extends \Doctrine\Tests\OrmTestCase
|
||||||
{
|
{
|
||||||
@ -90,4 +90,15 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals('baz', $q->getHint('bar'));
|
$this->assertEquals('baz', $q->getHint('bar'));
|
||||||
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints());
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user