Install

Works with Drupal: 7.x

Using Composer to manage Drupal site dependencies

Downloads

Download memcache-7.x-1.6-rc3.tar.gztar.gz 54.06 KB
MD5: 40c1aff4ef958a49b89a7f68e7ad3266
SHA-1: f5d7d8023a8465099b85def58138cb32fe2953f3
SHA-256: d281cacf62baa5b5c0f167e2caeb57bca8bfa719f2b51aa9364fbbb8fd9a5d51
Download memcache-7.x-1.6-rc3.zipzip 63.24 KB
MD5: 60d86b92c5429a1ad3ea1572de6a6a9f
SHA-1: 89d233a006ea5935dfd10fc1c52717757d3b4a01
SHA-256: 67f9049a6510b2c09b1cee7e677348a4f1332cc61ec7cfa93ae698a4a07f074e

Release notes

Narrowing In On A New Release

Help us test 7.x-1.6-rc3 to make sure there are no regressions compared to 7.x-1.5. Lots of bug fixes and useful new features were included in this release. The README is fully updated, documenting all new features that require configuration.

Always carefully test the update process and new release first in a development and/or staging environment before updating your production environment!

Highlights

  • Persistent connections are now enabled by default.
  • Introducing two memcache-specific drush commands; instantly flush an entire bin: drush mcf, review server statistics: drush mcs.
  • Improved debug output when memcache is misconfigured.
  • Properly handle over-sized cache items.
  • Support for the 'igbinary' and 'msgpack' extensions, optionally replacing php's serialize functions
  • PHP 7 support

What’s changed since 7.x-1.6-rc2

Overview

It's been two years since the last Drupal Memcache module release! Perhaps it's no coincidence that I also have a nearly two-year-old daughter. Excuses aside, there's a ton of important changes in this release, from optimizations and bug fixes to new features. What follows was extracted from the README.txt:

Drush
Enable the memcache module at admin/modules or with 'drush en memcache', then rebuild the drush cache by running 'drush cc drush'. This will enable the following drush commands:

  memcache-flush (mcf)  Flush all Memcached objects in a bin.
  memcache-stats (mcs)  Retrieve statistics from Memcached.

For more information about each command, use 'drush help'. For example:

  drush help mcf

Or:

  drush help mcs

Cache lifetime
Memcache respects Drupal core's minimum cache lifetime configuration. This setting affects all cached items, not just pages. In some cases, it may be desirable to cache different types of items for different amounts of time. You can override the minimum cache lifetime on a per-bin basis in settings.php. For example:

  // Cache pages for 60 seconds.
  $conf['cache_lifetime_cache_page'] = 60;
  // Cache menus for 10 minutes.
  $conf['cache_lifetime_menu'] = 600;

Cache header
Drupal core indicates whether or not a page was served out of the cache by setting the 'X-Drupal-Cache' response header with a value of HIT or MISS. If you'd like to confirm whether pages are actually being retreived from Memcache and not another backend, you can enable the following option:

  $conf['memcache_pagecache_header'] = TRUE;

When enabled, the Memcache module will add its own 'Drupal-Pagecache-Memcache' header. When cached pages are served out of the cache the header will include an 'age=' value indicating how many seconds ago the page was stored in the cache.

Persistent connections
As of 7.x-1.6, the memcache module uses peristent connections by default. If this causes you problems you can disable persistent connections by adding the following to your settings.php:

  $conf['memcache_persistent'] = FALSE;

Weighting servers
By default, all servers within a cluster have a weight of one, such as in this example:

  $conf['memcache_servers'] = array(
    '192.168.1.1:11211' => 'default',
    '192.168.1.2:11211' => 'default',
 );

You can optionally assign a different weight to each server, making it possible to favor one server more than another. To do so, you define the cluster within an array. For example, to make it 3 times more likely to store an item in the first server versus the second:

  $conf['memcache_servers'] = array(
    '192.168.1.1:11211' => array('cluster' => 'default', 'weight' => 3),
    '192.168.1.2:11211' => array('cluster' => 'default', 'weight' => 1),
 );

If the weight is not specified it defaults to 1, so the following configuration is identical to the above:

  $conf['memcache_servers'] = array(
    '192.168.1.1:11211' => array('cluster' => 'default', 'weight' => 3),
    '192.168.1.2:11211' => 'default',
 );

Prefixing
If you want to have multiple Drupal installations share memcached instances, you need to include a unique prefix for each Drupal installation in the $conf array of settings.php. This can be a single string prefix, or a keyed array of bin => prefix pairs:

   $conf['memcache_key_prefix'] = 'something_unique';

Using a per-bin prefix:

   $conf['memcache_key_prefix'] = array(
     'default' => 'something_unique',
     'cache_page' => 'something_else_unique'
   );

In the above example, the 'something_unique' prefix will be used for all bins except for the 'cache_page' bin which will use the 'something_else_unique' prefix. Note that if using a keyed array for specifying prefix, you must specify the 'default' prefix.

It is also possible to specify multiple prefixes per bin. Only the first prefix will be used when setting/getting cache items, but all prefixes will be cleared when deleting cache items. This provides support for more complicated configurations such as a live instance and an administrative instance each with their own prefixes and therefore their own unique caches. Any time a cache item is deleted on either instance, it gets flushed on both -- thus, should an admin do something that flushes the page cache, it will appropriately get flushed on both instances. (For more discussion see the issue where support was added, https://www.drupal.org/node/1084448.) This feature is enabled when you configure prefixes as arrays within arrays. For example:

  // Live instance.
  $conf['memcache_key_prefix'] = array(
    'default' => array(
      'live_unique', // live cache prefix
      'admin_unique', // admin cache prefix
    ),
  );

The above would be the configuration of your live instance. Then, on your administrative instance you would flip the keys:

  // Administrative instance.
  $conf['memcache_key_prefix'] = array(
    'default' => array(
      'admin_unique', // admin cache prefix
      'live_unique', // live cache prefix
    ),
  );

Experimental - Alternative Serialize
This is a new experimental feature added to the memcache module in version 7.x-1.6 and should be tested carefully before utilizing in production.

To optimize how data is serialized before it is written to memcache, you can enable either the igbinary or msgpack PECL extension. Both switch from using PHP's own human-readable serialized data strucutres to more compact binary formats.

No specicial configuration is required. If both extensions are enabled, memcache will automatically use the igbinary extension. If only one extension is enabled, memcache will automatically use that extension.

You can optionally specify which extension is used by adding one of the following to your settings.php:

  // Force memcache to use PHP's core serialize functions
  $conf['memcache_serialize'] = 'serialize';

  // Force memcache to use the igbinary serialize functions (if available)
  $conf['memcache_serialize'] = 'igbinary';

  // Force memcache to use the msgpack serialize functions (if available)
  $conf['memcache_serialize'] = 'msgpack';

To review which serialize function is being used, enable the memcache_admin
module and visit admin/reports/memcache.

IGBINARY

The igbinary project is maintained on GitHub:
- https://github.com/phadej/igbinary

The official igbinary PECL extension can be found at:
- https://pecl.php.net/package/igbinary

Version 2.0.1 or greater is recommended.

MSGPACK

The msgpack project is maintained at:
- https://msgpack.org

The official msgpack PECL extension can be found at:
- https://pecl.php.net/package/msgpack

Version 2.0.2 or greater is recommended.

Debug logging
You can optionally enable debug logging by adding the following to your settings.php:

  $conf['memcache_debug_log'] = '/path/to/file.log';

By default, only the following memcache actions are logged: 'set', 'add', 'delete', and 'flush'. If you'd like to also log 'get' and 'getMulti' actions, enble verbose logging:

  $conf['memcache_debug_verbose'] = TRUE;

This file needs to be writable by the web server (and/or by drush) or you will see lots of watchdog errors. You are responsible for ensuring that the debug log doesn't get too large. By default, enabling debug logging will write logs looking something like:

  1484719570|add|semaphore|semaphore-memcache_system_list%3Acache_bootstrap|1
  1484719570|set|cache_bootstrap|cache_bootstrap-system_list|1
  1484719570|delete|semaphore|semaphore-memcache_system_list%3Acache_bootstrap|1

The default log format is pipe delineated, containing the following fields:

  timestamp|action|bin|cid|return code

You can specify a custom log format by setting the memcache_debug_log_format variable. Supported variables that will be replaced in your format are: '!timestamp', '!action', '!bin', '!cid', and '!rc'. For example, the default log format (note that it includes a new line at the
end) is:

  $conf['memcache_debug_log_format'] = "!timestamp|!action|!bin|!cid|!rc\n";

You can change the timestamp format by specifying a PHP date() format string in the memcache_debug_time_format variable. PHP date() formats are documented at http://php.net/manual/en/function.date.php. By default timestamps are written as a unix timestamp. For example:

  $conf['memcache_debug_time_format'] = 'U';

Amazon Elasticache
You can use the Drupal Memcache module to talk with Amazon Elasticache, but to enable Automatic Discovery you must use Amazon's forked version of the PECL Memcached extension with Dynamic Client Mode enabled.

Their PECL Memcached fork is maintained on GitHub:
- https://github.com/awslabs/aws-elasticache-cluster-client-memcached-for-php

If you are using PHP 7 you need to select the php7 branch of their project.

Once the extension is installed, you can enable Dynamic Client Mode as follows:

  $conf['memcache_options'] = array(
    Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
    Memcached::OPT_CLIENT_MODE  => Memcached::DYNAMIC_CLIENT_MODE,
  );

You then configure the module normally. Amazon explains:

"If you use Automatic Discovery, you can use the cluster's Configuration
Endpoint to configure your Memcached client."

The Configuration Endpoint must have 'cfg' in the name or it won't work. Further documentation can be found here:
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Endpoints....

If you don't want to use Automatic Discovery you don't need to install the
forked PECL extension, Amazon explains:

"If you don't use Automatic Discovery, you must configure your client to use
the individual node endpoints for reads and writes. You must also keep track
of them as you add and remove nodes."

Details

Testing

The memcache module is a critical component of even the largest Drupal websites, so we take testing seriously. We have done comprehensive load testing of this release to ensure that there have been no performance regressions. Our load tests are freely available at https://github.com/tag1consulting/drupal-loadtest. There you will find scripts that assist in pre-populating a site with data and running a jMeter loadtest suite against the test website. While the tests aren’t comprehensive and only focus on common core functionality, they provide fantastic insight and detail into the performance differences between releases.

Created by: Jeremy
Created on: 17 Feb 2017 at 15:52 UTC
Last updated: 24 Feb 2017 at 16:33 UTC
Bug fixes
New features

Other releases