Loading...


Related Products


Date Published: November 20, 2025

Enabling APCu and ChainedFastBackend to speed up long Drush operations

Objective

Some Drush commands trigger long processes, such as search indexing, content migration, and so on that can benefit from adding the APCu local caching layer. 

This article explains how to enable the APCu PHP extension during a Drush invocation in Cloud Platform, so that Drupal can leverage it as a fast and local caching layer on top of the slower and remote cache backend, which is typically Memcache or database.

Prerequisites

  1. Access your Cloud Platform environment through SSH.

  2. Locate the drush.phpfile that is executable in your codebase. Typically, the path is: /var/www/html/vendor/drush/drush/drush.php.

  3. To verify that this method works for your site, run the following command and replace the path to the drush.php file if needed:

    php -d "extension=apcu.so" -d "apc.enable_cli=1" /var/www/html/vendor/drush/drush/drush.php ev 'echo "bin\tClass\n"; foreach (Drupal\core\Cache\Cache::getBins() as $name => $bin) { echo $name . "\t" . get_class($bin) . PHP_EOL; } ;' 
    • If the command shows a list where one or more cache bins use the Drupal\Core\Cache\ChainedFastBackend class, this method works for your site. 

    • If not, your site might have a code overriding the cache bin settings. Ensure that the code in your settings.php file or any files referenced from it do not override the cache backend for the discovery , config and bootstrap cache bins. Typically, these overrides are:

      $settings['cache']['bins']['CACHE-BIN-NAME-HERE'] = "cache.backend.BACKEND-NAME-HERE";

Enabling APCu on individual Drush runs

  1. Select the Drush invocations that you want to change. This may include Scheduled Jobs, Cloud Hooks, or custom scripting used by your site.
  2. Rewrite the Drush command to call PHP with the proper arguments:

    php -d "extension=apcu.so" -d "apc.enable_cli=1" /var/www/html/vendor/drush/drush/drush.php [drush arguments here]
  3. Remember to change the path to drush.php if it is in a different folder.

    For example, if your Drush command is:

    drush --uri=MYSITE.COM migrate:import 

    you must rewrite the command to:

    php -d "extension=apcu.so" -d "apc.enable_cli=1" /var/www/html/vendor/drush/drush/drush.php --uri=MYSITE.COM migrate:import

 

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation