麦进斗:在windows系统里面刷新magento2的缓存

下面的代码以编程方式刷新缓存。它为我工作得很好。

案例1:外磁

use Magento\Framework\App\Bootstrap;
include('../app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();


try{
    $_cacheTypeList = $objectManager->create('Magento\Framework\App\Cache\TypeListInterface');
    $_cacheFrontendPool = $objectManager->create('Magento\Framework\App\Cache\Frontend\Pool');
    $types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice');
    foreach ($types as $type) {
        $_cacheTypeList->cleanType($type);
    }
    foreach ($_cacheFrontendPool as $cacheFrontend) {
        $cacheFrontend->getBackend()->clean();
    }
}catch(Exception $e){
    echo $msg = 'Error : '.$e->getMessage();die();
}

案例2:在Magento

公共功能__construct(
上下文语境美元,
 \ \ \程序\缓存框架Magento \ typelistinterface cachetypelist美元,
 \ \ \程序\缓存框架Magento \前端\池cachefrontendpool美元
){ 
家长::__construct(合语境);
美元-> _cachetypelist = $ cachetypelist;
美元-> _cachefrontendpool = $ cachefrontendpool;
 } 
 
 
 $类型=阵列('config ','layout ','block_html ','collections ','reflection ','db_ddl ','eav ','config_integration ','config_integration_api ','full_page ','translate ','config_webservice ');
 foreach($类型达型){ 
美元-> _cachetypelist -> cleantype(合型);
 } 
 foreach(美元-> _cachefrontendpool达cachefrontend){ 
 cachefrontend美元-> getbackend()
分享 提高这个答案

转载于:https://www.cnblogs.com/magento-maijindou/p/5970291.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值