Cache backend options and storage reference
app/etc/env.php configuration.ece-tools package generates the resulting app/etc/env.php configuration during deployment based on the deploy variable configuration in .magento.env.yaml. You do not edit the env.php file. See Best Practices for Valkey and Redis Service Configuration and Deploy variables.The Commerce application uses a low-level cache frontend and backend to provide access to cache storage. Commerce supports several caching backends and strategies, each suited to different use cases. This page describes the available backends and how they differ.
Backend cache options
The following table summarizes the available backend caches:
var/cache/. No configuration required.Cache backend and L2 implementations implementation-approaches
Commerce supports direct cache backends and L2 caching. A direct backend selects cache storage. L2 caching adds a local cache layer in front of remote storage.
Direct cache backends
The following PHP examples configure the cache backend in <Commerce-install-dir>/app/etc/env.php. They do not enable L2 caching.
Magento\Framework\Cache\Backend\RedisMagento\Framework\Cache\Backend\ValkeyfilevalkeyFor exact patch-level support, see the System Requirements.
redis type name, but Redis is not an officially supported cache service where Valkey is required. Use valkey instead.Legacy Zend-based backend examples
For on-premises deployments, the following examples configure direct cache backends in <Commerce-install-dir>/app/etc/env.php. They do not enable L2 caching. Do not use these examples for Adobe Commerce on Cloud deployments, which use the ece-tools package to generate the resulting app/etc/env.php configuration during deployment.
Use the full Redis class name only on releases where Redis is supported:
| code language-php?start_inline=1 |
|---|
|
Use the full Valkey class name on releases that support the legacy Valkey backend:
| code language-php?start_inline=1 |
|---|
|
Modern Symfony Cache backend
The default direct backend is the file system. To use Valkey with the modern implementation, use the simplified valkey backend type.
The following configuration example is correct for Adobe Commerce 2.4.9 and later, and supported backports where Valkey is supported, when configuring direct default caching with the modern Symfony Cache implementation.
'cache' => [
'frontend' => [
'default' => [
'backend' => 'valkey',
'backend_options' => [
'server' => '127.0.0.1',
'database' => '0',
'port' => '6379',
],
],
],
],
L2 cache implementations
L2 (two-level) caching adds a local cache layer on each web node in front of shared remote cache storage, reducing network traffic between Commerce and the remote cache.
For on-premises configuration, see L2 cache configuration.
For Cloud projects, configure L2 caching through the deployment variables described in Deploy variables.
L2 cache configuration
-
For Adobe Commerce on-premises configuration details, see L2 cache configuration.
-
For Adobe Commerce on Cloud, configure L2 caching through the appropriate deployment variable rather than editing
app/etc/env.phpdirectly. See Deploy variables in the Adobe Commerce on Cloud documentation.