Tips for Updating Memcache Settings on the Acquia Platform

The "old method" for enabling memcache on the platform involved adding a configuration file in your codebase, and requiring it. The "new method"/best practice is to use a module to add the configuration file, so you can manage it using Composer.

This article is for you, if:

  • You want to enable memcache for the first time, to improve site performance, or
  • You know your memcache configuration is old, and you want to update for maximum performance, or
  • You have been notified that you need to update your memcache settings, such as, for migration to Acquia Cloud Next. 

Overview. To use memcache in D9/D10 on the Acquia platform requires the Drupal memcache module (drupal/memcache, 8.x-2.0 or later; ideally the current version) and a current memcache configuration file. Note that the drupal/memcache module needs to be present, but does not need to be installed/enabled. 

The memcache settings file can be added to your codebase manually (the old method), or by installing the acquia/memcache-settings module (the best practice method). Using the module is preferred, as it can be installed and updated using Composer. 

Once the memcache config file has been added to the codebase, it needs to be required in settings.php, or in a custom settings file that is called from settings.php. 

To require it in settings.php is the typical setup, but your site might have a custom settings file, such as “acquia.settings.php” (which in turn is required in settings.php) that contains some platform-specific configuration such as requiring the memcache settings file.

Docs are here: but here is some context and explanation, especially for a case where you are updating from an older configuration as opposed to installing memcache for the first time:

Enabling memcache for the first time. If your site doesn’t use memcache now, best practice is:

  • Require the latest version of drupal/memcache using Composer
  • Install the acquia/memcache-settings module using Composer (which adds the memcache configuration file in the vendor directory)
  • Edit the Acquia require line in settings.php to require the memcache configuration file provided by acquia/memcache-settings (see below)
  • Clear caches and test 

Updating from an old configuration. If the site uses an older memcache settings file, the best practice is:

  • Confirm that drupal/memcache module is version 8.x-2.0 or later. Ideally, update to the latest version.
  • Install acquia/memcache-settings module
  • Edit the Acquia require line in settings.php  (or a custom settings file, if the site uses this) to require the memcache configuration file provided by acquia/memcache-settings (see below)
  • Cleanup: Remove the old memcache configuration file
  • Clear caches (drush cr) and test

How to update the require line: 

  • Determine which file to edit. This will be settings.php, unless there is already a custom settings file with a require line for memcache config.
  • Find the require line. It will look similar to this, although it could be a little different, such as containing environment variables:
if (file_exists('/var/www/site-php')) {
[maybe some other things here]
  • Add or replace the memcache code, resulting in something like this (watch the formatting/brackets):
if (file_exists('/var/www/site-php')) {

   // Memcached settings for Acquia Hosting
   $memcache_settings_file = DRUPAL_ROOT . "/../vendor/acquia/memcache-settings/memcache.settings.php";
   if (file_exists($memcache_settings_file)) {
     require_once $memcache_settings_file;

If you see any caching issues directly after updating and running drush cr, it might be necessary to flush memcache, although normally you shouldn’t need to. See instructions here: