5

In my practice I've never really faced with situation that it was needed to clean the collection cache. It is strange)
I checked and detected that the magento uses the collection cache only for 4 entities:

website
store_group
store
category

These entities uses for their collections the virtual types based on

\Magento\Framework\Data\Collection\Db\FetchStrategy\Cache

which in turn uses \Magento\Framework\App\Cache\Type\Collection for defining the cache type - collection.

You can find the all SQL-queries which used (after md5 tranformation) as cache keys - see the fetchAll method.

And these SQL-queries only to tables which related to entities listed above.

Why doesn't magento use the collection cache for other entities, such as products or CMS-pages?

When should we use the collection cache for own custom entities?

1 Answer 1

2

Why doesn't magento use the collection cache for other entities, such as products or CMS-pages?

Doesn't need to. website, store_group and store are used in a lot of other logic but rarely change. The category entity is an interesting one. I can only assume because of the generation of category tree. So from a performance point of view. Although in my opinion is the one that stands out from the rest. Products are likely to change. CMS pages are single item collections.

When should we use the collection cache for own custom entities?

If what you implement is likely to impact performance (so a single large collection within a controller and/or rendered block logic) but contains data that won't change very often.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.