Starting from 2024, many Magento developers began migrating from Redis to Valkey — a community-driven fork developed after Redis switched to a non-open-source license.
Valkey maintains full API compatibility with Redis while offering continued open licensing, stability, and performance improvements.
In our case study, we focus on integrating Valkey with Magento 2.4.8 running on AlmaLinux 8 with cPanel. Below is the complete step-by-step configuration and testing guide used in production.
Why Choose Valkey for Magento?
Valkey is a drop-in replacement for Redis that brings:
- Open Source Freedom – fully maintained under the BSD license.
- Performance & Stability – identical speed, tested with Redis benchmarks.
- Full Compatibility – works seamlessly with Magento’s Redis cache adapters.
- Future-proof – community-driven roadmap independent from Redis Labs.
For eCommerce projects like Jaztime, where Valkey is heavily used for caching and sessions, Valkey integrates without code changes — only configuration updates are required.
Step-by-Step Setup: Integrating Valkey with Magento 2

Step 1: Install Valkey
dnf install valkey
This command installs Valkey from the official AlmaLinux repository.
After installation, the Valkey service becomes available system-wide.
Step 2: Enable and Start Service
systemctl enable --now valkey
This ensures Valkey automatically starts on system boot.
You can confirm its status with:
systemctl status valkey
Step 3: Configure Magento for Valkey
3.1 Open Configuration File
nano app/etc/env.php
3.2 Update Session Configuration
Below is the configuration taken and tested according to the official Magento 2 documentation.
Replace the session section to use Valkey (Redis-compatible configuration):
'session' => [
'save' => 'redis',
'redis' => [
'host' => '127.0.0.1',
'port' => '6379',
'password' => '',
'timeout' => '5',
'persistent_identifier' => '',
'database' => '0',
'compress_data' => '4',
'compress_tags' => '4',
'compression_threshold' => '20480',
'compression_library' => 'gzip',
'log_level' => '4',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '1',
'min_lifetime' => '60',
'max_lifetime' => '2592000',
]
],
Valkey supports all Redis session parameters used by Magento 2.
3.3 Update Cache Configuration
The cache section is also based on official Magento 2 documentation recommendations for using Valkey as a backend.
'cache' => [
'frontend' => [
'default' => [
'id_prefix' => '880_',
'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
'backend_options' => [
'server' => '127.0.0.1',
'database' => '1',
'port' => '6379',
'password' => '',
'compress_data' => '1',
'compression_lib' => '',
'preload_keys' => [
'880_EAV_ENTITY_TYPES',
'880_GLOBAL_PLUGIN_LIST',
'880_DB_IS_UP_TO_DATE',
'880_SYSTEM_DEFAULT',
],
]
],
'page_cache' => [
'id_prefix' => '880_',
'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
'backend_options' => [
'server' => '127.0.0.1',
'port' => '6379',
'database' => '2',
'password' => '',
'compress_data' => '0'
]
]
],
'allow_parallel_generation' => false
],
Don’t forget the comma , if you add this section before the last array element.
3.4 Apply Changes
After saving new configuration, clear the Magento cache:
bin/magento cache:flush
Step 4: Test Integration
To confirm Magento is storing data in Valkey, open or reload your storefront and run:
valkey-cli -n 0 --scan | tail -n 10
valkey-cli -n 1 --scan | tail -n 10
valkey-cli -n 2 --scan --pattern 'sess*' | tail -n 10
If you see keys like sess_* and mage-cache-*, everything works correctly.
This verifies that page cache, default cache, and sessions are now handled by Valkey.
Notes for Magento 2.4.9+
After updating to Magento 2.4.9, you need to recheck or update the env.php configuration, as changes in the core may affect the operation of the Redis/Valkey adapter.
Conclusion
Integrating Valkey into Magento 2 is fast, safe, and fully compatible.
It’s a perfect long-term alternative to Redis for open-source-based infrastructures.
Key benefits:
- Drop-in replacement for Redis
- Identical performance and structure
- Long-term open licensing and support
- Simple configuration via
env.php