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.
The following steps are applicable to Drupal 10 and later sites.
Access your Cloud Platform environment through SSH.
Locate the drush.phpfile that is executable in your codebase. Typically, the path is: /var/www/html/vendor/drush/drush/drush.php.
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";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]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
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Fri Nov 21 2025 07:05:56 GMT+0000 (Coordinated Universal Time)