Skip to content

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

Description

@ghanbari

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?

Activity

  1. teohhanhui commented on Jul 11, 2019

    @teohhanhui
    Contributor

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

  2. teohhanhui commented on Jul 11, 2019

    @teohhanhui
    Contributor

    Looking at the code, this is not currently possible.

  3. ghanbari commented on Jul 12, 2019

    @ghanbari
    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?

  4. teohhanhui commented on Jul 12, 2019

    @teohhanhui
    Contributor

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

    These should be easy to add. PRs welcome!

  5. oussj commented on Sep 17, 2019

    @oussj

    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 !

  6. oussj commented on Sep 23, 2019

    @oussj

    Hello @teohhanhui

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

    Thanks!

  7. oussj commented on Sep 30, 2019

    @oussj

    Hello @teohhanhui

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

    Thanks!

  8. teohhanhui commented on Sep 30, 2019

    @teohhanhui
    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
    
  9. oussj commented on Oct 12, 2019

    @oussj

    Ok thanks !
    I'm looking into it !

  10. bastnic commented on Oct 12, 2019

    @bastnic
    Contributor

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

  11. oussj commented on Oct 22, 2019

    @oussj

    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 ?

  12. locked and limited conversation to collaborators on Nov 6, 2022
  13. converted this issue into a discussion #5152 on Nov 6, 2022
  14. added theissue type on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions