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

Conversation

@pavelmaca
Copy link
Contributor

Using Cache Tags section has invalid example. Should use TagAwareCacheInterface.

@pavelmacapavelmaca changed the titleUpdate cache.rst[Cache] Fix example for using cache tags with TagAwareCacheInterfaceAug 15, 2019
@OskarStark
Copy link
Contributor

@Nyholm could you please verify this docs change? Thank you 😃

Nyholm reacted with thumbs up emoji

Copy link
Contributor

@OskarStarkOskarStark left a comment
edited
Loading

Choose a reason for hiding this comment

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

Thanks@pavelmaca for the change and@Nyholm for the review 👍

@Nyholm
Copy link
Member

Nyholm commentedAug 16, 2019
edited
Loading

Oh wait. I will review it shortly.

OskarStark reacted with thumbs up emojiOskarStark reacted with laugh emoji

Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Hey,
Thank you for this PR. TheTagAwareCacheInterface is an interface for the cache adapter. What we get passed to our function is a cache item.

@Nyholm
Copy link
Member

👎 (to be clear)

OskarStark reacted with thumbs up emoji

@OskarStark
Copy link
Contributor

@pavelmaca can you explain a bit why you did this change or which error do you have?

@Nyholm
Copy link
Member

I did find a bug when testing this out. Maybe that was what@pavelmaca experienced?

symfony/symfony#33201

cache.rst Outdated
use Symfony\Contracts\Cache\TagAwareCacheInterface;

$value0 = $pool->get('item_0', function (ItemInterface $item) {
$value0 = $pool->get('item_0', function (TagAwareCacheInterface $item) {
Copy link
Member

Choose a reason for hiding this comment

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

It is the$pool that should be aTagAwareCacheInterface.

@pavelmaca could you update this PR a little? Could you wrap this code into a function or a class and make sure$pool is aTagAwareCacheInterface?

@Nyholm
Copy link
Member

More info here:symfony/symfony#33201

@pavelmaca
Copy link
ContributorAuthor

@Nyholm Your findings are correct insymfony/symfony#33201

Updated doc with function and autowired $pool


$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
Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Oscar, what do you think? Should we create a class and use constructor injection or is that overkill?

It would be more clear since injection to a function is generally only used with controllers.

$value0 = $pool->get('item_0', function (ItemInterface $item) {
$item->tag(['foo', 'bar'])
// using autowiring
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?

@OskarStark
Copy link
Contributor

Oscar, what do you think? Should we create a class and use constructor injection or is that overkill?

I think this would make sense in this case, otherwise this must be a tage with controller arguments tag 👍

👍 for a class + injection

@javiereguiluz
Copy link
Member

I tried to merge this but I couldn't fix the conflicts ... so I created in#12398 a new pull request with these changes and all the other changes requested by Tobias.@pavelmaca I kept your original commit, so you'll get credit for this contribution. Thanks.

javiereguiluz added a commit that referenced this pull requestOct 1, 2019
…, javiereguiluz)This PR was merged into the 4.3 branch.Discussion----------[Cache] Improved the example about cache tagsThis continues the work started in#12181.Commits-------f9d438f Fixed code2651f92 [Cache] Improved the example about cache tagsce0c625 [Cache] Fix example for using cache tags with TagAwareCacheInterface
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

+1 more reviewer

@NyholmNyholmNyholm requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

5 participants

@pavelmaca@OskarStark@Nyholm@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp