Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / memcache / README.txt
index 6705434e024b2c856b30b8bb3a464c1053b9a686..de8b2ae6a8462b97b2436c152a87ccf1dff9b88d 100644 (file)
@@ -1,6 +1,6 @@
 ## IMPORTANT NOTE ##
 
-This file contains installation instructions for the 8.x-1.x version of the
+This file contains installation instructions for the 8.x-2.x version of the
 Drupal Memcache module. Configuration differs between 8.x and 7.x versions
 of the module, so be sure to follow the 7.x instructions if you are configuring
 the 7.x-1.x version of this module!
@@ -83,32 +83,6 @@ The bin/cluster/server model can be described as follows:
 
 - If a bin can not be found it will map to 'default'.
 
-### Stampede Protection ###
-
-Memcache includes stampede protection for rebuilding expired and invalid cache
-items. To enable stampede protection, add the following config in settings.php:
-
-$settings['memcache']['stampede_protection'] = TRUE;
-
-To avoid lock stampedes, it is important that you enable the memcache lock
-implementation when enabling stampede protection -- enabling stampede protection
-without enabling the Memcache lock implementation can cause worse performance.
-
-Only change the following values if you're sure you know what you're doing,
-which requires reading the memcachie.inc code.
-
-The value passed to Drupal\Core\Lock\LockBackendInterface::wait(), defaults to 5:
-  $settings['memcache']['stampede_wait_time'] = 5;
-
-The maximum number of calls to Drupal\Core\Lock\LockBackendInterface::wait() due
-to stampede protection during a single request, defaults to 3:
-  $settings['memcache']['stampede_wait_limit'] = 3;
-
-When adjusting these variables, be aware that:
- - wait_time * wait_limit is designed to default to a number less than
-   standard web server timeouts (i.e. 15 seconds vs. apache's default of
-   30 seconds).
-
 ### Prefixing ###
 
 If you want to have multiple Drupal installations share memcached instances,
@@ -117,7 +91,7 @@ config in settings.php:
 
   $settings['memcache']['key_prefix'] = 'something_unique';
 
-### Key Hash Algorithm
+### Key Hash Algorithm ###
 
 Note: if the length of your prefix + key + bin combine to be more than 250
 characters, they will be automatically hashed. Memcache only supports key
@@ -155,20 +129,17 @@ the default in this case but could be set using:
 
 Memcache locks can be enabled through the services.yml file.
 
-  services:
-    # Replaces the default lock backend with a memcache implementation.
-    lock:
-      class: Drupal\Core\Lock\LockBackendInterface
-      factory: memcache.lock.factory:get
-
-    # Replaces the default persistent lock backend with a memcache implementation.
-    lock.persistent:
-      class: Drupal\Core\Lock\LockBackendInterface
-      factory: memcache.lock.factory:getPersistent
+services:
+  # Replaces the default lock backend with a memcache implementation.
+  lock:
+    class: Drupal\Core\Lock\LockBackendInterface
+    factory: memcache.lock.factory:get
 
-## Cache Container on bootstrap ##
+## Cache Container on bootstrap (with cache tags on database) ##
 By default Drupal starts the cache_container on the database, in order to override that you can use the following code on your settings.php file. Make sure that the $class_load->addPsr4 is poiting to the right location of memcache (on this case modules/contrib/memcache/src)
 
+In this mode, the database is still bootstrapped so that cache tag invalidation can be handled. If you want to avoid database bootstrap, see the container definition in the next section instead.
+
 $memcache_exists = class_exists('Memcache', FALSE);
 $memcached_exists = class_exists('Memcached', FALSE);
 if ($memcache_exists || $memcached_exists) {
@@ -187,30 +158,89 @@ if ($memcache_exists || $memcached_exists) {
         'class' => 'Drupal\Core\Site\Settings',
         'factory' => 'Drupal\Core\Site\Settings::getInstance',
       ],
-      'memcache.config' => [
-        'class' => 'Drupal\memcache\DrupalMemcacheConfig',
+      'memcache.settings' => [
+        'class' => 'Drupal\memcache\MemcacheSettings',
         'arguments' => ['@settings'],
       ],
-      'memcache.backend.cache.factory' => [
-        'class' => 'Drupal\memcache\DrupalMemcacheFactory',
-        'arguments' => ['@memcache.config']
+      'memcache.factory' => [
+        'class' => 'Drupal\memcache\Driver\MemcacheDriverFactory',
+        'arguments' => ['@memcache.settings'],
+      ],
+      'memcache.timestamp.invalidator.bin' => [
+        'class' => 'Drupal\memcache\Invalidator\MemcacheTimestampInvalidator',
+        # Adjust tolerance factor as appropriate when not running memcache on localhost.
+        'arguments' => ['@memcache.factory', 'memcache_bin_timestamps', 0.001],
       ],
       'memcache.backend.cache.container' => [
-        'class' => 'Drupal\memcache\DrupalMemcacheFactory',
-        'factory' => ['@memcache.backend.cache.factory', 'get'],
+        'class' => 'Drupal\memcache\DrupalMemcacheInterface',
+        'factory' => ['@memcache.factory', 'get'],
         'arguments' => ['container'],
       ],
-      'lock.container' => [
-        'class' => 'Drupal\memcache\Lock\MemcacheLockBackend',
-        'arguments' => ['container', '@memcache.backend.cache.container'],
-      ],
       'cache_tags_provider.container' => [
         'class' => 'Drupal\Core\Cache\DatabaseCacheTagsChecksum',
         'arguments' => ['@database'],
       ],
       'cache.container' => [
         'class' => 'Drupal\memcache\MemcacheBackend',
-        'arguments' => ['container', '@memcache.backend.cache.container', '@lock.container', '@memcache.config', '@cache_tags_provider.container'],
+        'arguments' => ['container', '@memcache.backend.cache.container', '@cache_tags_provider.container', '@memcache.timestamp.invalidator.bin'],
+      ],
+    ],
+  ];
+}
+
+## Cache Container on bootstrap (pure memcache) ##
+By default Drupal starts the cache_container on the database, in order to override that you can use the following code on your settings.php file. Make sure that the $class_load->addPsr4 is poiting to the right location of memcache (on this case modules/contrib/memcache/src)
+
+For this mode to work correctly, you must be using the overridden cache_tags.invalidator.checksum service.
+See example.services.yml for the corresponding configuration.
+
+$memcache_exists = class_exists('Memcache', FALSE);
+$memcached_exists = class_exists('Memcached', FALSE);
+if ($memcache_exists || $memcached_exists) {
+  $class_loader->addPsr4('Drupal\\memcache\\', 'modules/contrib/memcache/src');
+
+  // Define custom bootstrap container definition to use Memcache for cache.container.
+  $settings['bootstrap_container_definition'] = [
+    'parameters' => [],
+    'services' => [
+      # Dependencies.
+      'settings' => [
+        'class' => 'Drupal\Core\Site\Settings',
+        'factory' => 'Drupal\Core\Site\Settings::getInstance',
+      ],
+      'memcache.settings' => [
+        'class' => 'Drupal\memcache\MemcacheSettings',
+        'arguments' => ['@settings'],
+      ],
+      'memcache.factory' => [
+        'class' => 'Drupal\memcache\Driver\MemcacheDriverFactory',
+        'arguments' => ['@memcache.settings'],
+      ],
+      'memcache.timestamp.invalidator.bin' => [
+        'class' => 'Drupal\memcache\Invalidator\MemcacheTimestampInvalidator',
+        # Adjust tolerance factor as appropriate when not running memcache on localhost.
+        'arguments' => ['@memcache.factory', 'memcache_bin_timestamps', 0.001],
+      ],
+      'memcache.timestamp.invalidator.tag' => [
+        'class' => 'Drupal\memcache\Invalidator\MemcacheTimestampInvalidator',
+        # Remember to update your main service definition in sync with this!
+        # Adjust tolerance factor as appropriate when not running memcache on localhost.
+        'arguments' => ['@memcache.factory', 'memcache_tag_timestamps', 0.001],
+      ],
+      'memcache.backend.cache.container' => [
+        'class' => 'Drupal\memcache\DrupalMemcacheInterface',
+        'factory' => ['@memcache.factory', 'get'],
+        # Actual cache bin to use for the container cache.
+        'arguments' => ['container'],
+      ],
+      # Define a custom cache tags invalidator for the bootstrap container.
+      'cache_tags_provider.container' => [
+        'class' => 'Drupal\memcache\Cache\TimestampCacheTagsChecksum',
+        'arguments' => ['@memcache.timestamp.invalidator.tag'],
+      ],
+      'cache.container' => [
+        'class' => 'Drupal\memcache\MemcacheBackend',
+        'arguments' => ['container', '@memcache.backend.cache.container', '@cache_tags_provider.container', '@memcache.timestamp.invalidator.bin'],
       ],
     ],
   ];
@@ -254,14 +284,14 @@ default options (selected through performance testing). These options will be
 set unless overridden in settings.php.
 
   $settings['memcache']['options'] = [
-    Memcached::OPT_COMPRESSION => FALSE,
+    Memcached::OPT_COMPRESSION => TRUE,
     Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
   ];
 
 These are as follows:
 
- * Turn off compression, as this takes more CPU cycles than it's worth for most
-   users
+ * Turn on compression, as this allows more data to be stored and in turn
+   should result in less evictions.
  * Turn on consistent distribution, which allows you to add/remove servers
    easily