How to configure Drupal to use Memcached Tutorial

Learn how to enable the use of the Memcached service on your Drupal website

This tutorial explains how to configure your Drupal application to use Memcached. By default, Drupal does not provide Memcached support. That is why you have to install a third party module which can be used by the Drupal system to connect to the Memcached service. You need to install Memcache API and Integration.

If your Drupal application is version 7.x you can install the module directly from your Drupal administrative area. Older Drupal applications (6.x) do not provide this functionality and you need to manually download the module to your computer. Then you have to upload the module to your account and extract the archive file. For more details how to manually install modules you can read this tutorial.

If you are using Drupal 7.x, first you have to access your Drupal administrative area and go to the Modules tab.

On the page that opens you will see all the installed modules and a link named Install new module. Click on it, so that you will be able to install the Memcached module.

You will be redirected to the module installation page on which you can see a text field named Install from a URL. In this field you should paste the link to the Memcache API and Integration module download link.

At the time of writing this tutorial the latest version of the module is 7.x-1.6 and the download link is:

https://ftp.drupal.org/files/projects/memcache-7.x-1.6.zip

You have to paste this link in the Install from a URL field and then click the Install button.

The module will be installed and you should proceed with its configuration. To configure the module properly you have to edit two files:

Inside these files you should change all occurrences of the following:

to

Make sure to replace your_memcached_port with the actual port for the Memcached service for your account. For more details how to find out the correct port you can check the this tutorial.

Once you have made the changes to the two files and saved them, all you need to do is to enable the module you installed. This is done from your Drupal admin area -> Modules tab. On the Modules page, scroll down to the bottom and find the Memcache and Memcache Admin modules and enable them.