With Copilot
Acquia Copilot is a conversational AI connected into our product documentation and knowledge base. Ask Copilot about product features, technical details, troubleshooting and how to get started with Acquia products.
Sign in to use Acquia Copilot
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:
memcache_key_prefix or memcache_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.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 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 then add the module to your codebase in the directory. Acquia recommends that you use Composer to install the module:
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 modules/contrib/memcache directory. Acquia recommends that you use Composer to install the module:
composer require drupal/memcacheFor environments running on Cloud Next technologies, you can adjust the memory allocated to Memcached as follows:
Sign in to the Cloud Platform user interface and select your application and environment.
Click Actions > Configure Environment.
Click Advanced.
In Memcached memory (MB), enter the amount of memory to allocate to Memcached. A value of 64 MB is the default value for applications running on Cloud Platform. However, you can increase the value depending on your application needs. Acquia recommends that you set a mid-range value of 128 MB or 256 MB. Thereafter, you can use the acquia-memcache stats command to determine if you need more or less memory depending on your usage and evictions.
You can leverage the Memcache binary protocol in Cloud Classic environments. However, Acquia does not recommend its use.
To use this protocol in Cloud Classic environments, ensure that you enable the Memcached::OPT_TCP_NODELAY flag in Memcache options to avoid slow fetches of empty cache items.
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 the define('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.
modules/contrib/memcachecomposer require drupal/memcacheFor Cloud Classic, do the following:
Add the Composer package that contains the Acquia Memcache settings to your project:
composer require acquia/memcache-settingsFor each website that requires Memcached, edit the Cloud Platform database require line in settings.php with a PHP require_once 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
$memcache_settings_file = DRUPAL_ROOT . "/../vendor/acquia/memcache-settings/memcache.settings.php";
if (file_exists($memcache_settings_file)) {
require_once $memcache_settings_file;
}
}The same steps must be used for CD environments because CD environments are not supported in Cloud Next.
Rebuild caches by running the following command, replacing [example.com] with the domain name of your website:
drush cr --uri=[example.com]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.
After you add the Memcache API and Integration module to your codebase through the preceding command, you do not need to additionally enable this module through the Drupal user interface or by using Drush.
cloud-memcache-d7.php, and add the contents of the file to your website’s settings.php file, after the Acquia database require line.Clear caches by running the following command, replacing [example.com] with the domain name of your website:
drush cc all --uri=[example.com]
cache_ tables in the database for the website.Memcache is now enabled for your website. If you need assistance, create a Support ticket.
Click Save.
For environments running on the Cloud Classic infrastructure, you must create a Support ticket to request that your Memcached memory allocation be modified. Larger amounts of memory can be allocated to Cloud Classic environments with dedicated Memcached infrastructure. Contact your Acquia account team for more information about this advanced configuration.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
modules/contrib/memcachecomposer require drupal/memcacheFor Cloud Classic, do the following:
Add the Composer package that contains the Acquia Memcache settings to your project:
composer require acquia/memcache-settingsFor each website that requires Memcached, edit the Cloud Platform database require line in settings.php with a PHP require_once 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
$memcache_settings_file = DRUPAL_ROOT . "/../vendor/acquia/memcache-settings/memcache.settings.php";
if (file_exists($memcache_settings_file)) {
require_once $memcache_settings_file;
}
}The same steps must be used for CD environments because CD environments are not supported in Cloud Next.
Rebuild caches by running the following command, replacing [example.com] with the domain name of your website:
drush cr --uri=[example.com]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.
After you add the Memcache API and Integration module to your codebase through the preceding command, you do not need to additionally enable this module through the Drupal user interface or by using Drush.
cloud-memcache-d7.php, and add the contents of the file to your website’s settings.php file, after the Acquia database require line.Clear caches by running the following command, replacing [example.com] with the domain name of your website:
drush cc all --uri=[example.com]
cache_ tables in the database for the website.Memcache is now enabled for your website. If you need assistance, create a Support ticket.
Click Save.
For environments running on the Cloud Classic infrastructure, you must create a Support ticket to request that your Memcached memory allocation be modified. Larger amounts of memory can be allocated to Cloud Classic environments with dedicated Memcached infrastructure. Contact your Acquia account team for more information about this advanced configuration.
If this content did not answer your questions, try searching or contacting our support team for further assistance.