Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #22960 [Cache] Fix decoration of TagAware adapters in dev (chalasr)
This PR was merged into the 3.3 branch. Discussion ---------- [Cache] Fix decoration of TagAware adapters in dev | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22956 | License | MIT | Doc PR | n/a Commits ------- 28e615a Fix decorating TagAware adapters in dev
- Loading branch information
Showing
4 changed files
with
77 additions
and
4 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
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
36 changes: 36 additions & 0 deletions
36
src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php
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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
/** | ||
* @author Robin Chalas <robin.chalas@gmail.com> | ||
*/ | ||
class TraceableTagAwareAdapter extends TraceableAdapter implements TagAwareAdapterInterface | ||
{ | ||
public function __construct(TagAwareAdapterInterface $pool) | ||
{ | ||
parent::__construct($pool); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function invalidateTags(array $tags) | ||
{ | ||
$event = $this->start(__FUNCTION__); | ||
try { | ||
return $event->result = $this->pool->invalidateTags($tags); | ||
} finally { | ||
$event->end = microtime(true); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php
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,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Tests\Adapter; | ||
|
||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use Symfony\Component\Cache\Adapter\TagAwareAdapter; | ||
use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; | ||
|
||
class TraceableTagAwareAdapterTest extends TraceableAdapterTest | ||
{ | ||
public function testInvalidateTags() | ||
{ | ||
$pool = new TraceableTagAwareAdapter(new TagAwareAdapter(new FilesystemAdapter())); | ||
$pool->invalidateTags(array('foo')); | ||
$calls = $pool->getCalls(); | ||
$this->assertCount(1, $calls); | ||
|
||
$call = $calls[0]; | ||
$this->assertSame('invalidateTags', $call->name); | ||
$this->assertSame(0, $call->hits); | ||
$this->assertSame(0, $call->misses); | ||
$this->assertNotEmpty($call->start); | ||
$this->assertNotEmpty($call->end); | ||
} | ||
} |