I want to create custom cache for top menu
For this I have created cache.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Cache/etc/cache.xsd">
<type instance="Vendor\Module\Model\Cache\Vmenu" name="vmenu_cache_tag" translate="label,description">
<label>vmenu</label>
<description>My Menu</description>
</type>
</config>
Also created Model/Cache/Vmenu.php
<?php
namespace Vendor\Module\Model\Cache;
class Vmenu extends \Magento\Framework\Cache\Frontend\Decorator\TagScope
{
const TYPE_IDENTIFIER = 'vmenu_cache_tag';
const CACHE_TAG = 'VMENU_CACHE_TAG';
/**
* @param \Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool
*/
public function __construct(
\Magento\Framework\App\Cache\Type\FrontendPool $cacheFrontendPool
) {
parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
}
}
Now my vmenu.phtml is calling from header.phtml
<?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Theme::html/vmenu.phtml")->toHtml(); ?>
My question is, how can I connect vmenu.phtml to my newly created cache?