Magento 2.0.18 is the final 2.0.x release. After March 2018, Magento 2.0.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Create a cache type

A cache type enables you to specify what is cached and enables merchants to clear that cache type using the Cache Management page in the Magento Admin .

The tag scope provides a mechanism for a cache type.

To create a new cache type:

class %Namespace%\%Module%\Model\Cache\Type extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
  const TYPE_IDENTIFIER = '%cache_type_id%';
  public function __construct(\Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool)
    parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);

You must specify the following parameters:

  • Namespace\Module defines the name of a module that uses a cache type. A module can use several cache types and a cache type can be used in several modules.
  • %cache_type_id% defines unique identifier of a cache type.
  • %CACHE_TYPE_TAG% defines unique tag to be used in the cache type scoping.

More information about caching

You can get more information about caching by looking at the code. We suggest you locate classes that extend Magento\Framework\Cache\Frontend\Decorator\TagScope.

For example, look at Magento\Eav\Model\Cache\Type to understand more about the EAV cache type.

Please help us improve this topic by suggesting details using the Edit this page in GitHub link at the top of the page.