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

[Cache] Fix example for using cache tags with TagAwareCacheInterface#12181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
pavelmaca wants to merge1 commit intosymfony:4.3frompavelmaca:patch-1
Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletionscache.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -487,21 +487,26 @@ use cache tags. One or more tags could be added to the cache item. All items wit
the same key could be invalidate with one function call::

use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;

$value0 = $pool->get('item_0', function (ItemInterface $item) {
$item->tag(['foo', 'bar'])
// using autowiring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
// using autowiring

Nyholm reacted with thumbs up emoji
public function listProducts(TagAwareCacheInterface $pool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Update$pool to$myCachePool to match the config below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe use a more generic name thanlistProducts. Maybefoo?

{
$value0 = $pool->get('item_0', function (ItemInterface $item) {
$item->tag(['foo', 'bar']);

return 'debug';
});
return 'debug';
});

$value1 = $pool->get('item_1', function (ItemInterface $item) {
$item->tag('foo')
$value1 = $pool->get('item_1', function (ItemInterface $item) {
$item->tag('foo');

return 'debug';
});
return 'debug';
});

// Remove all cache keys tagged with "bar"
$pool->invalidateTags(['bar']);
// Remove all cache keys tagged with "bar"
$pool->invalidateTags(['bar']);
}

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

[8]ページ先頭

©2009-2025 Movatter.jp