[On Premises]{class="badge informative" title="Applies to Adobe Commerce on-premises projects only."}

Cache backend options and storage reference

NOTE
This page documents on-premises app/etc/env.php configuration.
For Adobe Commerce on Cloud projects, the 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.

NOTE
Varnish handles full-page caching at the HTTP level for on-premises deployments. The Fastly service handles it for Cloud deployments. Neither solution uses the low-level cache backend.

Backend cache options

The following table summarizes the available backend caches:

Backend
Description
Configuration guide
File system
Default. Stores cache data in files under var/cache/. No configuration required.
N/A
Redis
In-memory data store for high-performance caching.
Use Redis for default cache
Valkey
Open-source, Redis-compatible alternative.
Use Valkey for default cache
Database
Custom cache engine backed by a database
Create custom cache engines (Adobe Developer documentation)
IMPORTANT
Redis cache is not supported for Adobe Commerce 2.4.9, or patch releases later than 2.4.5-p16, 2.4.6-p14, 2.4.7-p9, and 2.4.8-p4. If you are upgrading to one of these versions, configure Valkey and update the cache configuration to use it. For Adobe Commerce on-premises, see set up Valkey.

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.

Commerce version
Implementation
Backend
Configuration value
2.4.8 and earlier, where supported
Legacy
File system (default)
No configuration required
2.4.8 and earlier, where supported
Legacy
Redis
Magento\Framework\Cache\Backend\Redis
2.4.8 and earlier, where supported
Legacy
Valkey
Magento\Framework\Cache\Backend\Valkey
2.4.9 and later, plus supported backports
Modern Symfony Cache
File system (default)
file
2.4.9 and later, plus supported backports
Modern Symfony Cache
Valkey
valkey

For exact patch-level support, see the System Requirements.

NOTE
The modern implementation accepts the 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.

Legacy backend Redis

Use the full Redis class name only on releases where Redis is supported:

code language-php?start_inline=1
'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'database' => '0',
                'port' => '6379',
            ],
        ],
    ],
],
Legacy backend Valkey

Use the full Valkey class name on releases that support the legacy Valkey backend:

code language-php?start_inline=1
'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'Magento\\Framework\\Cache\\Backend\\Valkey',
            'backend_options' => [
                'server' => '127.0.0.1',
                'database' => '0',
                'port' => '6379',
            ],
        ],
    ],
],

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',
            ],
        ],
    ],
],
TIP
The Symfony Cache implementation supports optional performance features such as igbinary serialization, compression, Lua scripts, and persistent connections. For details, see Configure Valkey for Default and Page Cache.

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.

Commerce version
L2 implementation
Remote backend
Before 2.4.9, where supported
RemoteSynchronizedCache
Redis or Valkey, depending on the Commerce release and patch-level support matrix
2.4.9 and later
symfony_l2
Valkey

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.php directly. See Deploy variables in the Adobe Commerce on Cloud documentation.

recommendation-more-help
commerce-operations-help-configuration