Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc21b31d

Browse files
pavelmacajaviereguiluz
authored andcommitted
[Cache] Fix example for using cache tags with TagAwareCacheInterface
1 parentfc9fe33 commitc21b31d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

‎cache.rst‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -487,21 +487,26 @@ use cache tags. One or more tags could be added to the cache item. All items wit
487487
the same key could be invalidate with one function call::
488488

489489
use Symfony\Contracts\Cache\ItemInterface;
490+
use Symfony\Contracts\Cache\TagAwareCacheInterface;
490491

491-
$value0 = $pool->get('item_0', function (ItemInterface $item) {
492-
$item->tag(['foo', 'bar'])
492+
// using autowiring
493+
public function listProducts(TagAwareCacheInterface $pool)
494+
{
495+
$value0 = $pool->get('item_0', function (ItemInterface $item) {
496+
$item->tag(['foo', 'bar']);
493497

494-
return 'debug';
495-
});
498+
return 'debug';
499+
});
496500

497-
$value1 = $pool->get('item_1', function (ItemInterface $item) {
498-
$item->tag('foo')
501+
$value1 = $pool->get('item_1', function (ItemInterface $item) {
502+
$item->tag('foo');
499503

500-
return 'debug';
501-
});
504+
return 'debug';
505+
});
502506

503-
// Remove all cache keys tagged with "bar"
504-
$pool->invalidateTags(['bar']);
507+
// Remove all cache keys tagged with "bar"
508+
$pool->invalidateTags(['bar']);
509+
}
505510

506511
The cache adapter needs to implement:class:`Symfony\\Contracts\\Cache\\TagAwareCacheInterface``
507512
to enable this feature. This could be added by using the following configuration.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp