Redis Setup with Drupal 9
Here are Steps for configured Redis in Drupal 9 / Drupal 8 Project .
1) First I download Redis module for a Drupal 9 environment and stored it in 'modules/contrib' directory and enabled the same.
2) For the working of Redis module we need its libraries, so first you have to download the phpredis php extension library from https://github.com/nicolasff/phpredis. Extract the entire contents of the archive into the 'libraries/' folder.
3) If setup on local machine XAMPP then first configured redis on locally and configured php.ini : extension=redis and check phpinfo()

4) Ones Redis setup, After that update the settings.php file with the following code:
$settings['redis.connection']['interface'] = 'PhpRedis';
// Host ip address.
$settings['redis.connection']['host'] = '127.0.0.1';
$settings['cache']['default'] = 'cache.backend.redis';
// Redis port.
$settings['redis.connection']['port'] = '6379';
$settings['redis.connection']['base'] = 12;
// Password of redis updated in php.ini file.
$settings['redis.connection']['password'] = "password";
$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['config'] = 'cache.backend.chainedfast';5) Create services.yml inisde default folder and add the below code in it.

services:
# Cache tag checksum backend. Used by redis and most other cache backend
# to deal with cache tag invalidations.
cache_tags.invalidator.checksum:
class: Drupal\redis\Cache\RedisCacheTagsChecksum
arguments: ['@redis.factory']
tags:
- { name: cache_tags_invalidator }
# Replaces the default lock backend with a redis implementation.
lock:
class: Drupal\Core\Lock\LockBackendInterface
factory: ['@redis.lock.factory', get]
# Replaces the default persistent lock backend with a redis implementation.
lock.persistent:
class: Drupal\Core\Lock\LockBackendInterface
factory: ['@redis.lock.factory', get]
arguments: [true]
# Replaces the default flood backend with a redis implementation.
flood:
class: Drupal\Core\Flood\FloodInterface
factory: ['@redis.flood.factory', get]
Hope this is useful.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion