Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

Use Redis Cache Memcache Option on Azure with Drupal 7

Memcache is commonly used with Drupal sites to improve performance. If you find memcache client not supporting “Memcached Cloud” or Memcachier on Azure, here is a workaround

(refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-connect-to-redis-using-memcache-protocol/ ).

 

1. Setup Redis Cache Service on Azure:

 

2. Enable Memcache shim from Redis Cache:

From Azure management portal, add following app settings in CONFIGURE:

Copy REDIS_HOST, REDIS_KEY values from your Redis Cache subscription

Set MEMCACHESHIM_REDIS_ENABLE to true

Note: Enable NON-SSL port 6379 from Redis Cache if SSL port 6380 is not supported by client library.

 

3. Install PHP memcache extension (php_memcache.dll) for your website, (download memcache extension for windows from http://pecl.php.net/package/memcache/3.0.8/windows )

To add the PHP extension, copy the downloaded php_memcache.dll to wwwroot/bin/ folder, add PHP EXTENSIONS to “app settings” in Azure management portal.

For more detail, refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/

 

4. Download and install memcache module on your Drupal site ( https://www.drupal.org/project/memcache ), and add configuration in Settings.php:

 

$conf[‘memcache_servers’] = array(‘localhost:’.getenv(“MEMCACHESHIM_PORT”) => ‘default’);

$conf[‘cache_backends’][] = ‘sites/all/modules/memcache/memcache.inc’;

$conf[‘cache_default_class’] = ‘MemCacheDrupal’;

$conf[‘cache_class_cache_form’] = ‘DrupalDatabaseCache’;

$conf[‘memcache_key_prefix’] = ‘something_unique’;

 

5. To view cache hits, enable memcache from Drupal admin, and configure memcache statistic to show at bottom of pages, check the hit/miss ratio. View cache usage from Reids Cache account on Azure portal.