Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:29:40+00:00 2026-06-04T05:29:40+00:00

I have a problem with doctrine. I like the caching, but if i update

  • 0

I have a problem with doctrine. I like the caching, but if i update an Entity and flush, shouldn’t doctrine2 be able to clear it’s cache?
Otherwise the cache is of very little use to me since this project has a lot of interaction and i would literally always have to disable the cache for every query.
The users wouldn’t see their interaction if the cache would always show them the old, cached version.

Is there a way arround it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:29:42+00:00Added an answer on June 4, 2026 at 5:29 am

    This is according to the documentation on Doctrine2 on how to clear the cache. I’m not even sure this is what you want, but I guess it is something to try.

    Doctrine2’s cache driver has different levels of deleting cached entries.

    You can delete by the direct id, using a regex, by suffix, by prefix and plain deleting all values in the cache

    So to delete all you’d do:

    $deleted = $cacheDriver->deleteAll();
    

    And to delete by prefix, you’d do:

    $deleted = $cacheDriver->deleteByPrefix('users_');
    

    I’m not sure how Doctrine2 names their cache ids though, so you’d have to dig for that.

    Information on deleting cache is found here: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/caching.html#deleting

    To get the cache driver, you can do the following. It wasn’t described in the docs, so I just traced through the code a little.

    I’m assuming you have an entity manager instance in this example:

    $config = $em->getConfiguration(); //Get an instance of the configuration
    $queryCacheDriver = $config->getQueryCacheImpl(); //Gets Query Cache Driver
    $metadataCacheDriver = $config->getMetadataCacheImpl(); //You probably don't need this one unless the schema changed
    

    Alternatively, I guess you could save the cacheDriver instance in some kind of Registry class and retrieve it that way. But depends on your preference. Personally I try not to depend on Registries too much.

    Another thing you can do is tell the query you’re executing to not use the result cache. Again I don’t think this is what you want, but just throwing it out there. Mainly it seems you might as well turn off the query cache altogether. That is unless it’s only a few specific queries where you don’t want to use the cache.

    This example is from the docs: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/caching.html#result-cache

    $query = $em->createQuery('select u from \Entities\User u');
    $query->useResultCache(false); //Don't use query cache on this query
    $results = $query->getResult();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have what I assume is a configuration problem with my Doctrine schema.yml, but
I have a Like entity with a getDislike() function in my Symfony2-Doctrine2 project. Once
i have a problem with doctrine. I have a filemanager with folders and files.
I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
I have Problem with symfony i would like to execute the backend process from
I'm going through tutorials for doctrine and have come across a problem. Does the
I'm using Doctrine 2 ORM and I have this problem. I have three Entities,
I have a problem with doctrine2 in symfony2 app with postgres database. I get
I have i little problem with save Tags of an Portfolio with Doctrine. I
I have a problem with the toArray() method in Doctrine . Its doesn't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.