AdobeDocs / commerce-php

Source of the Commerce PHP Extensions guide

Home Page:https://developer.adobe.com/commerce/php/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using a custom created cache type is not clearly explained

zondario opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Which topic?

https://developer.adobe.com/commerce/php/development/cache/partial/cache-type/

What's wrong with the content?

Creating a cache type is super clear. But when it comes to using it there are questions that come up.
The biggest question is why when you create a cache type and declare it in cache.xml don't you use it instead of using CacheInterface (as shown). Every Magento module uses its own type in the constructor and saves/loads data through it. That grants you automatic checking if the cache is enabled or disabled (if you use CacheInterface which instantiates Magento\Framework\App\Cache\Proxy that does not work) and autopopulating the default cache tag of your custom cache type (if you use CacheInterface you are responsible for adding your tag).

What changes do you propose?

If the above is correct. I propose to show the usage of the newly created cache by injecting your own type and using it instead of CacheInterface. Feel free to correct my why this should not happen.

Anything else that can help to cover this?

No response