Memcache - Install memcached on linux and Drupal. | Drupal 8

Memcache - Install memcached on linux and Drupal.

Submitted by editor on Mon, 04/24/2017 - 11:43

How to install and configure memcached on debian 8 linux (or similar like ubuntu ...)  and setup with drupal 8 ?

Memcache is caching server allow you to incrise and have great performence on your site. Drupal and memcached work very well and here the full tutorial you need to install and setup memcache server and your drupal instance.

Install Mamcache

sudo apt-get install memcached

Start and get details

service memcached start
#Get details
service memcached status
ps -eaf | grep memcached
netstat -tap | grep memcached
#04 : Get full details
echo "stats settings" | nc localhost 11211


Memcache configuration

Memcached configuration file is located on :  /etc/memcached.conf
You can set the port, set memory size .... on this file.

Install PECL memcache packages

Chack :
php -m |grep mem
Install: (Not tested)
/usr/local/bin/pecl install memcache
Link :


Setup Drupal tu use memcached instead of the database.

Edit the settings.php and add m configuration.

//Memcache configuration
$settings['memcache']['servers'] = ['' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';

$settings['cache']['default'] = 'cache.backend.memcache';


How to check drupal using memcached not the database ?

1. TRUNCATE all tables start with cache_
2. Clear the cache using 'drush cr' or via interface.
-> If the tables start with cache_ does not contains any records, memcache is configured correctly. otherwise re check the configuration.
NOTE : Even correctly configured, Some times you can see 1 or two records in some tables. (memcache module is currently in development (Alpha version (2017/04/24)))

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.