Rana
Rana

Reputation: 6154

disable caching for a specific function in doctrine

I want to disable doctrine's default caching for a specific function(page), on all other pages, it should work as usual. Also I don't even want to clear the current caching inside that function. Just need that, no caching will be considered for that particular function call and its inside workflow.

Is there any easy way to achieve this? Thanks.

Upvotes: 1

Views: 2777

Answers (2)

nietonfir
nietonfir

Reputation: 4881

You could use another entity manager for that specific page with caching turned off. As you didn't mention what kind of framework you use, I am unable to make any further assumptions.

According to the documentation (and personal experience) you shouldn't use doctrine without a cache:

Do not use Doctrine without a metadata and query cache! Doctrine is optimized for working with caches. The main parts in Doctrine that are optimized for caching are the metadata mapping information with the metadata cache and the DQL to SQL conversions with the query cache. These 2 caches require only an absolute minimum of memory yet they heavily improve the runtime performance of Doctrine. The recommended cache driver to use with Doctrine is APC. APC provides you with an opcode-cache (which is highly recommended anyway) and a very fast in-memory cache storage that you can use for the metadata and query caches as seen in the previous code snippet.

Would you mind sharing that specific need of yours to be able to provide you with a better answer/solution to your problem?

Upvotes: 0

medina
medina

Reputation: 8159

Rana, I believe you can use $query->useResultCache(false); to disable the cache for the page you want. Take a look at the documentation if needed.

Cheers,

Upvotes: 2

Related Questions