Drupal Memcache

Posted : admin On 1/26/2022
  1. Php Memcached Example
  2. Drupal Memcache Session
  3. Php Memcache
  4. Distributed In Memory Cache
  5. Wordpress Memcache

Memcache Storage module provides integration between Drupal and Memcached daemon using PECL memcache or PECL memcached extension. Make sure that your Drupal server is installed with libmemcached and the PECL memcached extension. Take your Drupal site offline; Download and install the Drupal’s “Memcache API and Integration” module; To make Memcached the default cache class, edit your site’s settings.php file, as shown in the example below; Take your Drupal site. The Memcachecontributed project provides memcachedintegration and support for Drupal's caching, session, and lock backends. The following documentation describes how to configure the Memcache API and Integration (Memcache) module for Drupal 8. The Memcache module provides an API for using Memcached and the PECL Memcache or Memcached libraries with Drupal and provides backends for Drupal’s caching and locking systems.

Contents:

Php Memcached Example


Platform.sh recommends using Redis for caching with Drupal over Memcached, as Redis offers better performance when dealing with larger values as Drupal tends to produce. However, Memcached is also available if desired and is fully supported.

Drupal MemcacheDrupal memcache module

Requirements

Add a Memcached service

First you need to create a Memcached service. In your .platform/services.yaml file, add or uncomment the following:

In your .platform/services.yaml:

Now add a relationship in your .platform.app.yaml file:

Note:

You will need to use the memcached type when defining the service

and the endpoint memcached when defining the relationship

Your service_name and relationship_name are defined by you, but we recommend making them distinct from each other.

Drupal Memcache Session

Add the Memcached PHP extension

Memcache

You will need to enable the PHP Memcached extension. In your .platform.app.yaml file, add the following right after the type block:

Add the Drupal module

You will need to add the Memcache module to your project. If you are using Composer to manage your Drupal site (which we recommend), run:

Php Memcache

Then commit the resulting changes to your composer.json and composer.lock files.

Note:

Distributed In Memory Cache

You must commit and deploy your code before continuing, then enable the module. The memcachemodule must be enabled before it is configured in the settings.platformsh.php file.

Wordpress Memcache

Configuration

The Drupal Memcache module must be configured via settings.platformsh.php.

Place the following at the end of settings.platformsh.php. Note the inline comments, as you may wish to customize it further. Also review the README.txt file that comes with the memcache module, as it has a more information on possible configuration options. For instance, you may want to consider using memcache for locking as well and configuring cache stampede protection.

The example below is intended as a “most common case”.

Note:

If you do not already have the Platform.sh Config Reader library installed and referenced at the top of the file, you will need to install it with composer require platformsh/config-reader and then add the following code before the block below: