如何用命令行刷新,啟用,禁用Magento2的緩存


當你使用Magento商店時如何刷新Magento 2中的Cache命令行是基本的常用操作。Magento 2默認有12種緩存類型。在命令行中有5個簡單的命令來管理緩存。在這篇文章中,我將逐步向您展示每個命令行。

我將在這個截圖中解釋緩存管理

Magento 2刷新緩存命令行

刷新Magento 2緩存:

  • 轉到Magento根目錄
  • 類型:php bin/magento cache:cleanphp bin/magento cache:flush
  • 完成!去你的Magento商店,檢查結果。

在Ubuntu,Centos或Windows中更改當前目錄

  • Ubuntu的: cd /var/www/magento2
  • CentOS的: cd /var/www/html/magento2
  • Windows: cd /d/xampp/htdocs/magento2

在Windows的情況下,假如你安裝Xampp在D驅動器。

在Magento 2中,讓我們嘗試使用php bin/magento顯示命令行指南,它將顯示如下:


Magento CLI version 2

 

Usage:
command [options] [arguments]

Options:
–help (-h) Display this help message
–quiet (-q) Do not output any message
–verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
–version (-V) Display this application version
–ansi Force ANSI output
–no-ansi Disable ANSI output
–no-interaction (-n) Do not ask any interactive question

Available commands:
help Displays help for a command
list Lists commands
admin
admin:user:create Creates an administrator
admin:user:unlock Unlock Admin Account

cache
cache:clean Cleans cache type(s)
cache:disable Disables cache type(s)
cache:enable Enables cache type(s)
cache:flush Flushes cache storage used by cache type(s)

 

在本指南中,我將詳細討論Cache命令行管理。

檢查緩存狀態

首先,通過以下命令行來顯示緩存狀態:

  1. php bin/magento cache:status

緩存狀態的結果


Current status:
config: 1
layout: 1
block_html: 1
collections: 1
reflection: 1
db_ddl: 1
eav: 1
config_integration: 1
config_integration_api: 1
full_page: 1
translate: 1
config_webservice: 1

 

清理緩存命令行

  1. php bin/magento cache:clean

通過緩存類型使用命令行清除緩存存儲

緩存存儲可能包含其他數據,如服務器緩存。

  1. php bin/magento cache:flush

關閉緩存命令行

以下命令將禁用所有緩存類型

  1. php bin/magento cache:disable

如果你想禁用特定的緩存類型,應該輸入命令行

  1. php bin/magento cache:disable CACHE_TYPE

例如:

  1. php bin/magento cache:disable config

啟用緩存命令行

它類似於禁用緩存所有類型和特定的緩存類型

啟用所有緩存類型

  1. php bin/magento cache:enable

啟用特定的緩存類型

  1. php bin/magento cache:enable CACHE_TYPE

    1. php bin/magento cache:enable layout


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM