To enable Memcached on your website hosted by Cloud Platform, you must install the Memcache API and Integration module in your codebase, and 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
ormemcache_servers
settings, as Cloud Platform adds the correct values in Acquia-specific code defined by the Acquia require line, or otherwise available by default on Cloud Next. 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 the current Drupal version does not require you to enable the module, Acquia recommends you to enable 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.
Configuration for the current Drupal version
For Memcached to function, you must provide additional configuration code that enables autoloading, and identifies Memcached as an alternative cache back-end.
To configure your website for Memcached, make the following changes to your codebase, depending on your subscription type:
Download the Memcache API and Integration module and add the module to your codebase in the
modules/contrib/memcache
directory. We recommend to use Composer to install the module:composer require drupal/memcache
- Download
acsfd8+.memcache.settings.php
, and then add it to thefactory-hooks/post-settings-php
directory. For more information about the post-settings-php hook, see Altering values in settings.php with hooks. Rebuild caches by running the following command, replacing
[example.com]
with the domain name of your website:drush cr --uri=[example.com]
- Truncate all
cache_
tables in the database for the website.
Memcache is now enabled for your website. If you need assistance, create a Support ticket.
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:
- Download the Memcache API and Integration module, and then add the module to your codebase in the
sites/all/modules/contrib/memcache
directory. - Download
acsfd7.memcache.settings.php
, and add it to thefactory-hooks/post-settings-php
directory. For more information about the post-settings-php hook, see Altering values in settings.php with hooks. 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';
Clear caches by running the following command , replacing
[example.com]
with the domain name of your website:drush cc all --uri=[example.com]
- Truncate all
cache_
tables in the database for the website.
Memcache is now enabled for your website. Continue to read the next section.
If you need assistance, create a Support ticket.
Allocating memory to Memcached
Using binary protocol
Disabling auto-enablement of Memcached on Cloud Next
To disable Memcache integration with Drupal on Cloud Next, you can follow either of the following options:
Set the Memcache memory limit value to 0 through the Cloud Platform user interface or the Acquia Cloud API. This disables the Memcache service for every Drupal instance running within that environment.
Access the Drupal site’s
settings.php
file and add thedefine('AH_NO_MEMCACHE_INCLUDE', 1);
statement. This only controls the automatic injection of the Memcache integration code, and is independent from turning the Memcache service on or off. If you use this method, you must do the following. If you do not do these steps, the system might use Memcache with non-recommended configurations, thereby causing issues.Disable the Drupal memcache module.
Remove any integration code that adds the Memcache support from your
settings.php
file.
The Memcache binary protocol is not supported in Cloud Next environments. Cloud Next leverages mcrouter, which only supports the ASCII protocol for Memcache. If you enable binary protocol in Cloud Next environments, Drupal and PHP cannot communicate with Memcache servers. Therefore, the application fails to set or get cache items but does not return an error message.