How to integrate Redis into Drupal 8
Knowledgebase Article
}
Knowledgebase Article
Redis is one of the several backend cache systems supported by Drupal.
The way Redis works, is to cache the database queries on the first visit, and then serve the cached content to every other user that loads the same page, without querying the actual database.
The essential point of interest of utilizing Redis, is that store labels are upheld and the slower file system cache is no longer needed to be utilized.
Step 1: Set up Redis in cPanel
Take note of your "Your Redis socket address is" as you'll need it later:
Step 2: Enable the Redis PHP extension via the cPanel >> Select PHP Version:
Step 3: Install the Redis module from here as any other Drupal module:
Drupal Admin area >> Extend >> + Install new module >> Install from a URL >> https://www.drupal.org/project/redis >> Install:
Once the installation is completed, click on: Enable newly added modules and enable Redis:
Step 4: Configure Drupal 8 to use Redis!
Edit Drupal settings file: ./sites/default/settings.php and add these lines at the bottom of the file:
$settings['redis.connection']['host'] = '/home/USER/.kxcache/redis.sock'; $settings['redis.connection']['port'] = NULL; $settings['cache']['default'] = 'cache.backend.redis'; $settings['redis.connection']['base'] = 8;
where you'd need to replace the USER with your actual user (Step 1:) and the base id which should be unique redis database number dedicated for this cacheing.
The above code will configure Drupal to communicate over the UNIX socket and use it as a backend cache.
Redis runs as UNIX socket, which is ~116% faster, as no TCP connection is required to connect to it.
Step 5: Clear your Drupal cache: Admin >> Configuration >> Performance >> Clear all caches and then visit the status report page: Admin >> Reports >> Status report.
You should see an entry for Redis in there which will tell you if you are connected or not:
And that's how you integrate Redis into Drupal 8!
Should you need any further assistance, please do not hesitate to contact us.
Powered by WHMCompleteSolution