[仅限PaaS]{class="badge informative" title="仅适用于云项目(Adobe管理的PaaS基础架构)和内部部署项目上的Adobe Commerce 。"}
缓存类型
以下步骤逐步说明如何将缓存前端与缓存类型相关联。
步骤1:定义缓存前端
Commerce应用程序有一个default缓存前端,您可以将其用于任何缓存类型。 此部分讨论如何选择性地使用不同的名称定义缓存前端,如果您希望自定义前端,最好使用不同的名称。
必须指定自定义缓存前端app/etc/env.php或Commerce的全局app/etc/di.xml。
以下示例说明如何在env.php文件中定义它,它将覆盖di.xml文件:
'cache' => [
'frontend' => [
'<unique frontend id>' => [
<cache options>
],
],
'type' => [
<cache type 1> => [
'frontend' => '<unique frontend id>'
],
],
'type' => [
<cache type 2> => [
'frontend' => '<unique frontend id>'
],
],
],
其中<unique frontend id>是用于标识前端的唯一名称,<cache options>是特定于每种缓存类型(数据库、Redis等)的主题中讨论的选项。
步骤2:配置缓存
您可以在env.php或di.xml中指定前端和后端缓存配置选项。 此任务是可选的。
env.php示例:
'frontend' => <frontend_type>,
'frontend_options' => [
<frontend_option> => <frontend_option_value>,
...
],
'backend' => <backend_type>,
'backend_options' => [
<backend_option> => <backend_option_value>,
...
],
位置
-
<frontend_type>是低级前端缓存类型。 指定与Zend\Cache\Core兼容的类的名称。
如果省略<frontend_type>,则使用Magento\Framework\Cache\Core。 -
<frontend_option>,<frontend_option_value>是Commerce框架在创建时作为关联数组传递给前端缓存的选项的名称和值。 -
<backend_type>是低级后端缓存类型。 指定与Zend_Cache_Backend兼容且实现Zend_Cache_Backend_Interface的类的名称。 -
<backend_option>和<backend_option_value>是Commerce框架在创建时作为关联数组传递给后端缓存的选项的名称和值。
有关最新的Zend信息,请参阅Laminas文档。