File tree Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -489,23 +489,33 @@ the same key could be invalidate with one function call::
489489 use Symfony\Contracts\Cache\ItemInterface;
490490 use Symfony\Contracts\Cache\TagAwareCacheInterface;
491491
492- // using autowiring
493- public function listProducts(TagAwareCacheInterface $pool)
492+ public function SomeClass
494493 {
495- $value0 = $pool->get('item_0', function (ItemInterface $item) {
496- $item->tag(['foo', 'bar']);
494+ private $myCachePool;
497495
498- return 'debug';
499- });
496+ // using autowiring to inject the cache pool
497+ public function __construct(TagAwareCacheInterface $myCachePool)
498+ {
499+ $this->myCachePool = $myCachePool;
500+ }
500501
501- $value1 = $pool->get('item_1', function (ItemInterface $item) {
502- $item->tag('foo');
502+ public function someMethod()
503+ {
504+ $value0 = $this->myCachePool->get('item_0', function (ItemInterface $item) {
505+ $item->tag(['foo', 'bar']);
503506
504- return 'debug';
505- });
507+ return 'debug';
508+ });
506509
507- // Remove all cache keys tagged with "bar"
508- $pool->invalidateTags(['bar']);
510+ $value1 = $this->myCachePool->get('item_1', function (ItemInterface $item) {
511+ $item->tag('foo');
512+
513+ return 'debug';
514+ });
515+
516+ // Remove all cache keys tagged with "bar"
517+ $this->myCachePool->invalidateTags(['bar']);
518+ }
509519 }
510520
511521The cache adapter needs to implement :class: `Symfony\\ Contracts\\ Cache\\ TagAwareCacheInterface` `
You can’t perform that action at this time.
0 commit comments