-
-
Notifications
You must be signed in to change notification settings - Fork 9
Not possible to disable memcache, causing slow page loads #84
Description
Even if you have cache set to false in .lando.yml (as documented here: https://docs.lando.dev/plugins/acquia/config.html), and do not have a Drupal memcache module installed (disabled for local development environment using config_split Drupal module), memcache related code will run on every page load, causing significant slowness.
While investigating why my site was so slow, I found this issue:
#10
A user there pointed out something extremely problematic for anyone who does not have the Drupal memcache module enabled and configured and does not want to. The issue is caused by the interplay of Lando setting $_ENV['AH_SITE_ENVIRONMENT'] to "LANDO", and the memcache related code in the Acquia created/controlled docroot/sites/default/settings/cloud-memcache-d8.php file.
In cloud-memcache-d8.php, this if statement will ALWAYS be true:
/**
* Use memcache as cache backend.
*
* Autoload memcache classes and service container in case module is not
* installed. Avoids the need to patch core and allows for overriding the
* default backend when installing Drupal.
*
* @see https://www.drupal.org/node/2766509
*/
if (array_key_exists('memcache', $settings) &&
array_key_exists('servers', $settings['memcache']) &&
!empty($settings['memcache']['servers'])
) {
This is because Lando sets the $_ENV['AH_SITE_ENVIRONMENT'] variable, and Acquia creates the $settings['memcache'] array in another Acquia settings file.
Initially I thought I could unset the array in my local.settings.php, but this is not possible, because local.settings.php is ran AFTER cloud-memcache-d8.php.
The only way I have found to avoid this if statement being true is to unset $_ENV['AH_SITE_ENVIRONMENT'] in .lando.yml:
services:
appserver:
overrides:
environment:
AH_SITE_ENVIRONMENT:
This likely has side effects, or else Lando wouldn't bother to set the variable in the first place. However, after adding that and running lando rebuild, my site is significantly faster. Using Xdebug, I can confirm that the if statement in cloud-memcache-d8.php evaluates to false and the memcache code does not run.
Can we find a way to actually disable memcache that plays nicely with Acquia files that we have no control over?