2018年3月14日星期三

Magento2开发教程 - 缓存失效和私有内容版本

缓存失效

Magento 2实体变化后可以清空缓存,立即查看效果。我们使用 IdentityInterface 将应用程序中的实体与缓存的内容连接起来,并知道当实体改变时要清除哪些缓存。
本节讨论当你改变一个实体时如何告知Magento 2应用清除缓存。
首先,你的实体模块必须实现 Magento/Framework/DataObject/IdentityInterface 如下:
use Magento\Framework\DataObject\IdentityInterface;
 
class Product implements IdentityInterface
{
 
     /**
      * Product cache tag
      */
     const CACHE_TAG = 'catalog_product';
 
    /**
     * Get identities
     *
     * @return array
     */
    public function getIdentities()
    {
         return [self::CACHE_TAG . '_' . $this->getId()];
    }
}
其次,块对象也必须实现 Magento/Framework/DataObject/IdentityInterface 如下:
class View extends AbstractProduct implements \Magento\Framework\DataObject\IdentityInterface
{
    /**
     * Return identifiers for produced content
     *
     * @return array
     */
    public function getIdentities()
    {
        return $this->getProduct()->getIdentities();
    }
}

私人内容版本

私有内容存储在浏览器本地存储中,使用private_content_version cookie存储版本.

2 条评论:

  1. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    回复删除
  2. I can’t say much but with my experience through divorce, I had no one until I met hackingsetting50@gmail.com online then I contacted him, surprisingly he helped me hack into my partner's phone and all his social media platforms and i can now access everything and even documented and printed stuffs to show as evidence , now I’m happy with my kids and working for Riches. I hope this helps anyone in need.

    Thanks.

    回复删除

注意:只有此博客的成员才能发布评论。

Also Read: