Information for: DEVELOPERS   PARTNERS

Enabling Memcached on Acquia Cloud

About Memcached

Memcached is not available for use with Acquia Cloud Free.

To enable Memcached on your website hosted by Acquia Cloud, you must first install the Memcache API and Integration module in your codebase, and then configure the module for use.

When configuring your website to use Memcached, be aware of the following considerations:

  • Do not edit the memcache_key_prefix or memcache_servers settings, as Acquia Cloud adds the correct values in Acquia-specific code defined by the Acquia require line. Altering these values can cause unexpected behavior.
  • If your website uses either automated testing or the memcache_admin submodule, you must enable the Memcache API and Integration module. Although Drupal 8 doesn’t require you to enable the module, Acquia recommends enabling the module to receive notifications about module updates.
  • For more information about stampede protection and database locking, see Enabling stampede protection and moving locks into memory.

Important

Be sure to test any of the procedures provided by this documentation page on a non-production environment before implementing them on your production environment.

Configuration for Drupal 8

For Memcached to function, you must provide additional configuration code that enables autoloading, and identifies Memcached as an alternative cache backend during Drupal’s website installation process.

To configure your Drupal 8 website for Memcached, make the following changes to your codebase, depending on your subscription type:

  1. Download the Memcache API and Integration module, and then add the module to your codebase in the modules/contrib/memcache directory.

  2. Download cloud-memcache-d8.php, and then add it to your codebase in the sites/default directory.

  3. For each website that requires memcached, edit the Acquia Cloud database require line in settings.php with a PHP include() or require() statement, similar to the following example:

    if (file_exists('/var/www/site-php')) {
       require('/var/www/site-php/mysite/mysite-settings.inc');
    
       // Memcached settings for Acquia Hosting
       if (file_exists(DRUPAL_ROOT . '/sites/default/cloud-memcache-d8.php')) {
          require(DRUPAL_ROOT . '/sites/default/cloud-memcache-d8.php');
       }
    }
    
  4. Rebuild caches by running the following command, replacing [example.com] with the domain name of your website:

    drush cr --uri=[example.com]
    
  5. Truncate all cache_ tables in the database for the website.

Memcache is now enabled for your website. If you need assistance, contact Acquia support.

  1. Download the Memcache API and Integration module, and then add the module your codebase in the modules/contrib/memcache directory.

  2. Download acsfd8.memcache.settings.php, and then add it to the factory-hooks/post-settings-php directory. For more information about the post-settings-php hook, see Altering values in settings.php with hooks.

  3. Edit the file, modifying sections marked with // MODIFY THIS NEXT LINE with the appropriate path to the Memcache API and Integration module.

  4. Rebuild caches by running the following command, replacing [example.com] with the domain name of your website:

    drush cr --uri=[example.com]
    
  5. Truncate all cache_ tables in the database for the website.

Memcache is now enabled for your website. If you need assistance, contact Acquia support.

For Acquia BLT users

Acquia BLT users that continue to experience issues should submit a ticket to the Acquia BLT issue queue.

Configuration for Drupal 7

If you are installing the module on a Drupal 7 website, you must enable the module before modifying settings.php, or you will receive a ServiceNotFoundException: error message.

To configure your Drupal 7 website for Memcached, make the following changes to your codebase, depending on your subscription type:

  1. Download the Memcache API and Integration module, and then add the module to your codebase in the sites/all/modules/contrib/memcache directory.

  2. Download cloud-memcache-d7.php, and then add the contents of the file to your website’s settings.php file, after the Acquia database require line.

  3. Clear caches by running the following command, replacing [example.com] with the domain name of your website:

    drush cc all --uri=[example.com]
    
  4. Truncate all cache_ tables in the database for the website.

Memcache is now enabled for your website. If you need assistance, contact Acquia support.

  1. Download the Memcache API and Integration module, and then add the module to your codebase in the sites/all/modules/contrib/memcache directory.

  2. Download acsfd7.memcache.settings.php, and then add it to the factory-hooks/post-settings-php directory. For more information about the post-settings-php hook, see Altering values in settings.php with hooks.

  3. Edit the file, modifying the following lines if they do not correspond to the location of the Memcache API and Integration module in your codebase:

    $conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
    
    $conf['lock_inc'] = 'sites/all/modules/contrib/memcache/memcache-lock.inc';
    
  4. Clear caches by running the following command , replacing [example.com] with the domain name of your website:

    drush cc all --uri=[example.com]
    
  5. Truncate all cache_ tables in the database for the website.

Memcache is now enabled for your website. If you need assistance, contact Acquia support.

Allocating memory to Memcached on Acquia Cloud Professional

This section applies only to Acquia Cloud Professional.

To allocate memory to Memcached on Acquia Cloud Professional and enable it to run, use the following procedure:

  1. Sign in to Acquia Cloud and select your application, and then select the environment.

  2. In the left menu, click Servers.

  3. In the card for the web server, click the Configure link.

    The Acquia Cloud user interface displays the Configure link

  4. In the Memcached memory (MB) field, enter the amount of memory to allocate to Memcached. A value of 64 MB is the default value for applications running on Acquia Cloud, but you may increase the value depending on the needs of your application.

  5. Click Save.