Using Memcached with Drupal
To use Memcached as a cache for your Drupal site, follow the instructions provided in “Memcached / Installation” page of Drupal’s documentation. The required steps are:
- 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.phpfile, as shown in the example below
- Take your Drupal site back online
settings.php should resemble the following snippet:
$conf['cache_backends'] = 'sites/all/modules/memcache/memcache.inc'; // The 'cache_form' bin must be assigned no non-volatile storage. $conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; $conf['cache_default_class'] = 'MemCacheDrupal'; $conf['memcache_key_prefix'] = 'default'; $conf['memcache_servers'] = array( 'hostname:port' => 'default' ); $conf['memcache_sasl_auth'] = array( 'user' => 'username', 'password' => 'password' );
- In line 6, the value should be your bucket’s endpoint
- In line 7, the first value should be your bucket’s username
- In line 7, the second value should be your bucket’s password
Using Multiple Memcached Buckets
Although a single Memcached bucket can be used for all of your site’s needs, it is possible to use multiple buckets via the bins mechanism. The following snippet demonstrates the use of two Memcached buckets – the first for all data and the second for users:
$conf['memcache_servers'] = array( 'hostname1:port1' => 'default', 'hostname2:port2' => 'users' ); $conf['memcache_bins'] = array( 'cache' => 'default', 'users' => 'users' );
Redis Enterprise enables running Memcached buckets in a highly available and auto-scalable manner, with predictable top performance.
Redis Enterprise Software lets you install an enterprise grade Memcached cluster in your environment of choice, whether an on-premises data-center or your preferred cloud platform. It gives you full control of your data and configuration – no clustering or sharding knowledge required!
Memcached Cloud is a fully managed cloud service for hosting and running Memcached datasets in a highly available and scalable manner, with predictable and stable top performance. It provides a storage engine for standard Memcached, as well as in-memory replication and instant auto-failover within the same data center or across data centers. The service completely frees developers from dealing with nodes, clusters, scaling, data persistence issues or failure recovery.
For more information on using Redis Labs’ products and services with Drupal please see the Howto page.