Skip to content

Commit 358132f

Browse files
committed
Make TraceableAdapter TagAware
1 parent adc39a2 commit 358132f

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/Symfony/Component/Cache/Adapter/TraceableAdapter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
2121
* @author Nicolas Grekas <p@tchwork.com>
2222
*/
23-
class TraceableAdapter implements AdapterInterface
23+
class TraceableAdapter implements TagAwareAdapterInterface
2424
{
2525
private $pool;
2626
private $calls = array();
@@ -168,6 +168,19 @@ public function commit()
168168
}
169169
}
170170

171+
/**
172+
* {@inheritdoc}
173+
*/
174+
public function invalidateTags(array $tags)
175+
{
176+
$event = $this->start(__FUNCTION__, $tags);
177+
try {
178+
return $event->result = $this->pool->invalidateTags($tags);
179+
} finally {
180+
$event->end = microtime(true);
181+
}
182+
}
183+
171184
public function getCalls()
172185
{
173186
try {

src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
15+
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
1516
use Symfony\Component\Cache\Adapter\TraceableAdapter;
1617

1718
/**
@@ -184,4 +185,20 @@ public function testCommitTrace()
184185
$this->assertNotEmpty($call->start);
185186
$this->assertNotEmpty($call->end);
186187
}
188+
189+
public function testInvalidateTags()
190+
{
191+
$pool = new TraceableAdapter(new TagAwareAdapter(new FilesystemAdapter()));
192+
$pool->invalidateTags(array('foo'));
193+
$calls = $pool->getCalls();
194+
$this->assertCount(1, $calls);
195+
196+
$call = $calls[0];
197+
$this->assertSame('invalidateTags', $call->name);
198+
$this->assertSame(array('foo'), $call->argument);
199+
$this->assertSame(0, $call->hits);
200+
$this->assertSame(0, $call->misses);
201+
$this->assertNotEmpty($call->start);
202+
$this->assertNotEmpty($call->end);
203+
}
187204
}

0 commit comments

Comments
 (0)