缓存管理
缓存类型概述
| 缓存类型"friendly"名称 | 缓存类型标识代码 | 描述 | 
|---|---|---|
Configuration  | 
                config  | 
                
 Magento2收集配置所有的模块,将它合并,节省了合并结果的缓存。该缓存还包含存储在文件系统和数据库中的特定存储设置。 修改配置文件后,清除或刷新此缓存类型.  | 
              
Layout  | 
                layout  | 
                
 已编译的页面布局(即所有组件的布局组件)。 修改布局文件后,清除或刷新此缓存类型.  | 
              
Block HTML output  | 
                block_html  | 
                
 HTML 页面或者 block. 修改视图层后,清除或刷新缓存类型。  | 
              
Collections data  | 
                collections  | 
                数据库查询结果.  | 
              
DDL  | 
                db_ddl  | 
                
 数据库 schema. 自动更新数据库模式的一种方法是使用 magento setup:db-schema:upgrade 命令.  | 
              
Entity attribute value (EAV)  | 
                eav  | 
                以EAV属性相关的元数据(例如,存储标签,链接到相关的PHP代码,属性渲染,搜索设置,等等)。  | 
              
Page cache  | 
                full_page  | 
                生成的HTML页面.  | 
              
Reflection  | 
                reflection  | 
                删除的WebAPI模块和客户模块之间的依赖关系。 | 
Translations  | 
                translate  | 
                从所有模块合并翻译.  | 
              
Integration configuration  | 
                config_integration  | 
                
 编译的集成。 更改或添加Integration后清除或刷新此缓存。  | 
              
Integration API configuration  | 
                config_integration_api  | 
                编译集成的API.  | 
              
web services configuration  | 
                config_webservice  | 
                Web API 结构.  | 
              
第一步
- 
                
登录到Magento服务器切换到Magento 2文件系统的所有者用户要有写入的权限.
如果你使用Bash shell,你也可以使用下面的语法转换到Magento文件系统所有者:
su <Magento 2文件系统所有者> -s /bin/bash -c <command> sudo -u <Magento 2文件系统所有者> <command> 
您也可以按下列方式运行命令:
- 
cd <Magento 2 安装目录>/bin并运行它们./magento <command name> php <Magento 2 安装目录>/bin/magento <command name>
除了这里讨论的命令参数外,请参见常见参数.
查看缓存状态
要查看缓存的状态,请输入
magento cache:status 
            一个示例如下:
                    config: 1
                    layout: 1
                block_html: 1
               collections: 1
                    db_ddl: 1
                       eav: 1
                 full_page: 1
                 translate: 1
        config_integration: 1
    config_integration_api: 1
         config_webservice: 1
            启用或禁用缓存类型
此命令使您能够启用或禁用所有缓存类型或仅指定的缓存类型。禁用缓存类型是有用在开发中,无需刷新缓存就可以查看改变;然而,禁用缓存类型对性能有负面影响。
命令选项:
magento cache:enable [type] ... [type]
magento cache:disable [type] ... [type] 
            启用缓存类型自动清除缓存类型。
清理和刷新缓存类型
若要清除缓存中的过期项目,您可以使用 clean 或 flush 缓存类型:
命令的用法:
magento cache:clean [type] ... [type]
magento cache:flush [type] ... [type]
            例如,要刷新所有缓存类型,请输入
magento cache:flush
            示例结果:
Flushed cache types:
config
layout
block_html
collections
db_ddl
eav
full_page
translate
config_integration
config_integration_api
config_webservice
            你也可以在magento 2 后台管理缓存. System > Tools > Cache Management. Flush Cache Storage .
相关话题
- 索引管理
 - 配置和运行cron(定时任务)
 - 代码编译
 - Magento 2 模式(mode)设置
 - URN(统一资源名称)高亮显示
 - 依赖报告(Dependency reports)
 - 翻译和语言包
 - 部署静态视图文件
 - 运行单元测试
 - 转换layout(布局) xml 文件
 - 性能测试生成数据