This article describes how to configure Drupal 9 to use Redis.
Redis is an open-source memory object caching system that websites can use to help accelerate page load times. Redis works by caching in RAM frequently accessed data, such as the results of API calls, database calls, and more.
First, you must install some dependencies and a module so Drupal can access and use Redis. To do this, follow these steps:
composer require predis/predis composer require drupal/redis cp modules/contrib/redis/example.services.yml sites/default/redis.services.yml
After you install and enable the Redis module, you are ready to configure Drupal to actually use Redis. To do this, follow these steps:
$settings['redis.connection']['interface'] = 'Predis'; $settings['redis.connection']['host'] = 'localhost'; $settings['redis.connection']['port'] = '6379'; $settings['cache']['default'] = 'cache.backend.redis'; $settings['container_yamls'][] = 'sites/default/redis.services.yml';
If you have a Turbo shared or reseller account, copy the following text and append it to the settings.php file. Replace username with your account username:
$settings['redis.connection']['interface'] = 'Predis';
$settings['redis.connection']['host'] = '/home/username/.redis/redis.sock';
$settings['redis.connection']['port'] = NULL;
$settings['cache']['default'] = 'cache.backend.redis';
$settings['container_yamls'][] = 'sites/default/redis.services.yml';
Save your changes to the settings.php file. Redis is now configured for Drupal.
For more information about Redis, please visit https://redis.io.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.