麦进斗:在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()
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步