Skip to main content

Cloudsoft Zone Build, deploy and scale with practical guides to PHP, Node.js, React, DevOps and AI automation. Explore the guides

Cloudsoft Zone
MagentoDevOpsTutorial

How to move Magento cache and sessions from Redis to Valkey

Adobe now tests Magento and Adobe Commerce with Valkey instead of Redis, and 2.4.9 uses Valkey options in bin/magento. Learn which version you need and how to configure default cache, page cache and sessions.

Cloudsoft Zone

Updated 7 min read

Wide view of rack-mounted servers with front panels and network cables in a server room
Photograph: Victorgrigas / CC BY-SA 3.0, via Wikimedia Commons
In this article

For years the standard advice for a fast Magento store was simple: put the application cache, the full-page cache and PHP sessions in Redis. That advice has changed. Adobe now lists Valkey, the open-source fork of Redis, as the tested cache service for every supported release line, and from version 2.4.9 the bin/magento tooling itself uses Valkey options instead of Redis ones.

Adobe's 2.4.9 release notes give the reason: Redis 7.2 end of support and Redis licensing changes. Its Valkey documentation adds that Valkey is required for cache configuration on 2.4.9 and on the patch releases later than 2.4.5-p16, 2.4.6-p14, 2.4.7-p9 and 2.4.8-p4. In other words, if you applied the May 2026 security patches, you are expected to be on Valkey.

This tutorial shows how to point the Magento default cache, the page cache and session storage at Valkey on an on-premises installation, how the commands differ between 2.4.9 and 2.4.8, and how to check the result. Adobe Commerce on cloud infrastructure has its own service configuration, which Adobe documents separately.

Which Valkey version you need

Adobe's system requirements (updated 18 September 2026) list these tested versions for the latest patch of each line:

Magento / Adobe CommerceValkeyRedis
2.4.99Not listed
2.4.8-p58.1Not listed
2.4.7-p108.1Not supported
2.4.6-p158.1Not supported
2.4.7-p9 and 2.4.6-p14 (previous patches)87.2

Valkey speaks the same protocol as Redis and Adobe describes it as near-identical in functionality, so PHP clients such as the phpredis extension work with it. Installing Valkey itself is outside the scope of Adobe's guide and of this article; use your operating system's packages or the official Valkey releases, and pin the major version from the table.

If you are still on an older patch, such as 2.4.7-p9 or 2.4.6-p14, Redis 7.2 remains a tested option for that exact patch. Moving to Valkey at the same time as you apply the next security patch keeps the two changes aligned with Adobe's tables and avoids running an untested combination in production.

Plan the layout before you switch

Magento stores three different kinds of data, and each has different needs:

  • Default cache (configuration, layouts, blocks). It can be rebuilt at any time, so it needs no persistence. Adobe suggests sizing it from your current var/cache folder: if that folder holds 5 GB, start with at least 5 GB of memory.
  • Full-page cache. Also disposable. Many production stores use Varnish for this instead, which Adobe supports (Varnish 8 for current releases).
  • Sessions. Losing them signs customers out and empties guest carts, so Adobe recommends persistence: RDB snapshots, an append-only file (AOF), or both.

Adobe gets the best results from a dedicated instance for each of sessions, cache and full-page cache. If you share one instance, the database numbers must differ; Adobe recommends 0 for the default cache, 1 for the page cache and 2 for sessions. The examples below use one local instance with those numbers.

Valkey project logo with the word valkey in dark lettering and a stylised key symbol
Valkey is an open-source fork of Redis that keeps the Redis protocol.

Configure Valkey on Magento 2.4.9

Use setup:config:set rather than editing app/etc/env.php by hand. Adobe recommends the command line because it validates the configuration. Run the commands as the file system owner from the Magento root:

Shell
# Default (application) cache in database 0
bin/magento setup:config:set --cache-backend=valkey \
  --cache-backend-valkey-server=127.0.0.1 \
  --cache-backend-valkey-port=6379 \
  --cache-backend-valkey-db=0

# Full-page cache in database 1 (skip if Varnish handles page caching)
bin/magento setup:config:set --page-cache=valkey \
  --page-cache-valkey-server=127.0.0.1 \
  --page-cache-valkey-port=6379 \
  --page-cache-valkey-db=1

# Sessions in database 2
bin/magento setup:config:set --session-save=valkey \
  --session-save-valkey-host=127.0.0.1 \
  --session-save-valkey-port=6379 \
  --session-save-valkey-db=2

If Valkey requires a password, add --cache-backend-valkey-password, --page-cache-valkey-password and --session-save-valkey-password. Pass secrets from your deployment tooling rather than typing them into shell history, and remember that env.php then contains the password, so keep it out of version control.

On 2.4.9 the resulting env.php cache section uses the short backend name valkey, because 2.4.9 replaced Zend_Cache with the Symfony Cache component:

PHP
'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'valkey',
            'backend_options' => [
                'server' => '127.0.0.1',
                'database' => '0',
                'port' => '6379'
            ],
        ],
        'page_cache' => [
            'backend' => 'valkey',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => '6379',
                'database' => '1',
                'compress_data' => '0'
            ]
        ]
    ]
],

Configure Valkey on 2.4.8 and earlier

Before 2.4.9 there are no valkey options in the CLI. Adobe's session guide explains that the Redis commands stay the same and simply point at a Valkey server, which keeps migration simple. Use the familiar Redis options with your Valkey host and port:

Shell
bin/magento setup:config:set --cache-backend=redis \
  --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0
bin/magento setup:config:set --page-cache=redis \
  --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1
bin/magento setup:config:set --session-save=redis \
  --session-save-redis-host=127.0.0.1 --session-save-redis-db=2

These commands write the Magento\Framework\Cache\Backend\Redis backend into env.php. Adobe's Valkey page also shows a Zend-based Magento\Framework\Cache\Backend\Valkey class for 2.4.8 and earlier. When you later upgrade to 2.4.9, rerun the configuration with the valkey options.

Session settings worth knowing

The session handler has many options. These are the ones that most often matter in production, with Adobe's documented defaults:

OptionDefaultWhat it does
session-save-valkey-max-concurrency6How many processes may wait for a lock on one session. Adobe suggests at least 10% of your PHP processes on large clusters.
session-save-valkey-break-after-frontend5 secondsWhen to break a stuck storefront session lock
session-save-valkey-break-after-adminhtml30 secondsThe same for Admin sessions
session-save-valkey-bot-first-lifetime60 secondsShort first lifetime for bot sessions, which keeps crawlers from filling memory
session-save-valkey-compression-threshold2048Compress session data above this size; 0 disables compression
session-save-valkey-max-lifetime2592000 (30 days)Upper limit for any session

Sentinel options (session-save-valkey-sentinel-master and session-save-valkey-sentinel-servers) are available for highly available setups.

Close-up of the back of a server rack with white Ethernet cables and small blue LED displays
Give sessions their own persistent instance; cache data can always be rebuilt.

Tune Valkey and PHP for Magento

Adobe's Redis configuration guide recommends asynchronous deletion settings that do not change behaviour but reduce latency spikes. They apply equally to a Valkey configuration file:

Text
# Asynchronous deletion settings from Adobe's Redis configuration guide
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
lazyfree-lazy-user-del yes

For 2.4.9 stores, Adobe's cache guide recommends the native phpredis extension over the pure-PHP Predis client, and the igbinary serializer when you use Symfony Cache. Install the igbinary PHP extension, then set the serializer in env.php:

PHP
'cache' => [
    'frontend' => [
        'default' => [
            'backend_options' => [
                'server' => '127.0.0.1',
                'database' => '0',
                'port' => '6379',
                'serializer' => 'igbinary'
            ]
        ]
    ]
],

Leave the Lua options at their defaults unless you have a specific reason: Adobe documents use_lua as 0 and use_lua_on_gc as 1, and warns that changing them on 2.4.7 or 2.4.8 can cause cache corruption or silently failing tag-based invalidation.

Check that it works

Flush the cache, load a few storefront pages and sign in to the Admin, then confirm that keys appear in the expected databases:

Shell
bin/magento cache:flush
bin/magento cache:status
valkey-cli -n 0 dbsize
valkey-cli -n 2 dbsize

The key counts should grow as you browse. If the storefront shows errors, check var/log/exception.log for connection errors, confirm the host, port and password, and make sure the Valkey server is reachable from every web node and from the cron server.

Common mistakes and how to avoid them

Most Valkey problems in Magento come from a handful of configuration choices rather than from Valkey itself. Check this list before you go live and again after every infrastructure change.

MistakeEffectHow to avoid it
Cache and sessions in the same database numberFlushing the cache signs every customer outUse separate database numbers (0, 1, 2) or, better, separate instances
No persistence on the session instanceA Valkey restart empties carts and ends Admin sessionsEnable RDB snapshots, AOF or both for sessions
Cache instance too smallConstant evictions and slower pagesSize it from var/cache and monitor memory use
Valkey reachable from the internetData exposure and abuseBind to private interfaces, require a password and firewall the port
Only clearing var/cache after deploymentsStale configuration served from ValkeyUse bin/magento cache:flush, which clears the configured backend

Rolling back

Before you switch, copy app/etc/env.php. If the new setup misbehaves, restore the copy and flush the cache; Magento will reconnect to the previous backend. Expect active sessions to be lost when you move session storage in either direction, so schedule the change for a quiet period and tell your support team in advance.

Next steps

Moving to Valkey is now a supported-configuration requirement rather than an optimisation. Install the Valkey major version that matches your release, keep cache, page cache and sessions in separate databases or instances, enable persistence for sessions, and use the valkey CLI options from 2.4.9 onwards. Then add Valkey memory use and evictions to your monitoring, so that you notice before the cache outgrows its instance.

Frequently asked questions

  • Why did Adobe switch Magento from Redis to Valkey?

    Adobe's 2.4.9 release notes cite Redis 7.2 end of support and Redis licensing changes. Valkey is an open-source fork that keeps the Redis protocol.

  • Do I need to change PHP extensions for Valkey?

    No. Valkey uses the Redis protocol, so the phpredis extension works. Adobe recommends phpredis over Predis and igbinary serialization on 2.4.9.

  • Which database numbers should I use?

    Adobe recommends 0 for the default cache, 1 for the page cache and 2 for sessions when they share an instance. Separate instances are better still.

  • Should Valkey persist the cache to disk?

    Not for caches, which Magento can rebuild. Enable RDB or AOF persistence for the session instance so customers are not signed out after a restart.

Advertise on CloudSoftZone

Your next customer could start right here.

Introduce your tool, product or business to readers exploring technology.

Advertise with us

Explore placements and request a private quote

Sources

  1. Use Valkey for default and page cache — Adobe Experience League
  2. Use Valkey for session storage — Adobe Experience League
  3. System requirements (Adobe Commerce) — Adobe Experience League
  4. Adobe Commerce 2.4.9 release notes — Adobe Experience League
  5. Configure Redis — Adobe Experience League
  6. Use Redis for default and page cache — Adobe Experience League

Written with substantial AI assistance. Facts checked against cited sources. Editorial policy.

Comments

No comments yet. Be the first to join the conversation.

Leave a comment

Every comment is read by a moderator before it appears. Your email address is never published; it is used only to contact you about this comment.

Never published. Used only to contact you about this comment.

Loading the security check…

Comments are moderated before publication.