Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is exists anyway to disable cache invalidation in runtime? #2926

Closed
ghanbari opened this issue Jul 11, 2019 · 11 comments
Closed

is exists anyway to disable cache invalidation in runtime? #2926

ghanbari opened this issue Jul 11, 2019 · 11 comments

Comments

@ghanbari
Copy link

Hi, I have some command that do heavy work, but for some reason i don't need to purge cache,
I want to disable cache invalidation for those commands, i removed PurgeHttpCacheListener listener from entityManager.

is exists anyway to disable cache invalidation by calling a service method?

@teohhanhui
Copy link
Contributor

Do you mean to disable the cache tags only for certain operations?

@teohhanhui
Copy link
Contributor

Looking at the code, this is not currently possible.

@ghanbari
Copy link
Author

Do you mean to disable the cache tags only for certain operations?

No, i want to disable cache tags for certain resource or for all resource in certain console commands.

Looking at the code, this is not currently possible.

I check code and didn't saw anything, maybe we have this feature in future?

@teohhanhui
Copy link
Contributor

I don't see the support for disabling cache tags for a certain resource either.

These should be easy to add. PRs welcome!

@oussj
Copy link

oussj commented Sep 17, 2019

Hello @teohhanhui
Would love to help on this matter as I'm experiencing the same problem.
First, which developer interface do you have in mind for this feature.
As I see it, I see three options :

  • an Annotation on a service that would disable the cache invalidation temporarly
/**
 * @DisableCachePurge
 */
class MyMassiveImportCommand
{ 
  • an interface that would implement a enableCachePurge and disableCachePurge method
interface ControlCachePurgeInterface
{
    public function enableCachePurge();
    
    public function disableCachePurge();
}

Do you think one of these solutions would be apropriate ?

Thanks !

@oussj
Copy link

oussj commented Sep 23, 2019

Hello @teohhanhui

What do you think about the solutions I suggested? Do you have a better idea to fix this?

Thanks!

@oussj
Copy link

oussj commented Sep 30, 2019

Hello @teohhanhui

Were you able to have a look at the solution I suggested? Looking forward to have your feedbacks and other ideas!

Thanks!

@teohhanhui
Copy link
Contributor

@oussj Thanks for the suggestions, but I don't think they're the right ones for this case. 😄

If you want to disable cache purging for a certain console command, that should already be possible by using e.g.

api_platform:
    http_cache:
        invalidation:
            enabled: '%env(bool:CACHE_INVALIDATION_ENABLED)%'
$ CACHE_INVALIDATION_ENABLED=0 bin/console app:my:command

@oussj
Copy link

oussj commented Oct 12, 2019

Ok thanks !
I'm looking into it !

@bastnic
Copy link
Contributor

bastnic commented Oct 12, 2019

@oussj subject mentioned in #3168, where I do heavy work but not in a situation where I can benefit of an env var.

@oussj
Copy link

oussj commented Oct 22, 2019

hello @teohhanhui
so from what I see what you proposed is already a solution actually to this issue. Moreover the fix proposed by @bastnic in #3168 resolves this issue too. Should you close this issue ?

@soyuka soyuka removed the question label Nov 6, 2022
@api-platform api-platform locked and limited conversation to collaborators Nov 6, 2022
@soyuka soyuka converted this issue into discussion #5152 Nov 6, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

6 participants