11/30/2021

Drupal 8 Memcache

– PHP tuning including Opcache, Interned strings and apcu – Varnish, Memcache, and Database tips – The Software Stack, with Drupal 8 integration tips. ©2016 Acquia Inc. — Confidential and Proprietary Mitigate against Failure by planning for Success!! I read a few very good online resources that describe how exactly we can implement Memcache in Drupal 8. This one https://www.valuebound.com/resources/blog.

  1. Drupal 8 Clear Memcache
  2. Drupal 8 Requirements
Memcache

Below you will find instructions on configuring your Drupal project to work with Docksal.Some settings are required; others are optional or enhancements. Please review carefully.

Drupal 8 memcache settings.php

DB Connection Settings (required)

Below are sample settings for Drupal 7 and Drupal8.

Drupal 7 and 8

Drupal

File permissions fix (required)

To make sure files and folders generated by Drupal are writable add the following to your settings.php file.

Drupal 8 Memcache

Drupal 7

Drupal 8

You may also have to reset permissions on the existing files folder.The following command will recursively set folders to 777 (rwx) and files to 666 (rw).

Reverse Proxy Settings (optional)

In some cases you have to let Drupal know if HTTPS is used. Add the following lines to settings.php:

Drupal 7

Drupal 8

Memcache Settings (optional)

Follow Memcached instructions.

Use memcached:11211 as the memcached endpoint.

Drupal 7

Edit settings.php and add the following lines to point Drupal to the memcached service.
Replace </path/to/memcache-module> with the path to memcache module in your project, e.g., sites/all/modules/contrib/memcache.

Drupal 8 Memcache

Drupal 8

Drupal 8 Clear Memcache

Enable the Memcache module in Drupal.

Configuring memcache in Drupal 8 requires the Memcache module to first be enabled.(Re)installing a Drupal 8 site with these settings will fail.Comment the settings out, (re)install, then uncomment the settings back.

Drupal 8 Requirements

Edit settings.php and add the following lines to point Drupal to the memcached service.