Adding Memcached to Drupal Previews

If your Drupal site uses memcached in production, you may also want to add a memcached service to your Tugboat Previews.

In your Tugboat config.yml. Install the memcached library and pecl driver. Also add a memcached service.

 1services:
 2  php:
 3    image: tugboatqa/php:8.3-apache
 4    commands:
 5      init:
 6        - apt-get update
 7        - apt-get install libzip-dev libmemcached-dev zlib1g-dev libssl-dev
 8        - echo yes '' | pecl install -f memcached-3.2.0
 9        - docker-php-ext-enable opcache zip memcached
10
11  # Add a memcached container
12  memcached:
13    image: tugboatqa/memcached:latest

In your Tugboat Drupal settings.php add the reference to the memcache container with default options.

1// Memcache on Tugboat
2$settings['memcache']['servers'] = ['memcached:11211' => 'default'];
3$settings['memcache']['bins'] = ['default' => 'default'];
4$settings['memcache']['key_prefix'] = '';
5$settings['cache']['default'] = 'cache.backend.memcache';