The README would benefit from a few modifications to correct outdated config and additional examples of common settings such as:

- How to configure memcache settings without requiring the module to be installed first
- Using memcache as a backend for non default bins for core ~8.2.x
- Installing Drupal using memcache as an alternative backend
- Updated information on chained fast backend bin defaults and configuration

Issue fork memcache-2934916

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lcatlett created an issue. See original summary.

lcatlett’s picture

The attached patch updates the README with :

- How to configure memcache settings without requiring the module to be installed first
- Using memcache as a backend for non default bins for core ~8.2.x
- Updated per-bin settings
- Installing Drupal using memcache as an alternative backend
- Updated information on chained fast backend bin defaults and per-bin configuration
- Additional troubleshooting information

These updates will likely help close several open issues reported as module bugs with the provided settings updates and troubleshooting information.

anavarre’s picture

Status: Active » Needs work

Disclaimer: I haven't tested the suggested recommendations in settings.php - This is more a review to make the patch ready-to-go otherwise.

  1. +++ b/README.txt
    @@ -24,20 +24,23 @@ These are the steps you need to take in order to use this software. Order
    + 2. Enable the memcache module before you configure memcache to run
    

    s/configure memcache/configure it

  2. +++ b/README.txt
    @@ -24,20 +24,23 @@ These are the steps you need to take in order to use this software. Order
    +    as the default backend. This is so Drupal knows where to find everything. ¶
    

    Extra space at EOL.

  3. +++ b/README.txt
    @@ -24,20 +24,23 @@ These are the steps you need to take in order to use this software. Order
    +    Enabling the module prior to configuring memcache backends is not required ¶
    

    Extra space at EOL.

  4. +++ b/README.txt
    @@ -24,20 +24,23 @@ These are the steps you need to take in order to use this software. Order
    +    if the configuration "Autoloading Memcache Classes / Services" is being used. ¶
    

    Extra space at EOL. Also should be wrapped at 80 cols.

  5. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +    // Define custom bootstrap container definition to use Memcache for cache.container.
    

    Should be wrapped at 80 cols.

  6. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +Since Drupal 8.2.x cache bins such as config, bootstrap, and discovery will ¶
    

    Extra space at EOL. Also, this paragraph could be reworked such as we use as much of the 80 cols limit as possible.

  7. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +By autoloading the required classes and cache services as well as configuring Drupal to
    

    Should be wrapped at 80 cols.

  8. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +bootstrap using memcache for cache.container, memcache bins can be configured in ¶
    

    Extra space at EOL.

  9. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +settings.php before the module is enabled. This will prevent errors such as ¶
    

    Extra space at EOL.

  10. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +"non-existent cache service" when the memcache backend is not yet available but is ¶
    

    Extra space at EOL + line should be wrapped at 80 cols.

  11. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +configured in settings.php. This strategy also allows for overriding the default backend
    

    Should be wrapped at 80 cols.

  12. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +when installing Drupal which can be necessary when using modules such as ¶
    

    Extra space at EOL.

  13. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +content_translation that override default configuration at runtime. Insert the following
    

    Should be wrapped at 80 cols. Since "Insert the following to settings.php" is to introduce an example to add to settings.php, it could also be a new line.

    Also, "Insert the following in settings.php", maybe?

  14. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +  if ($memcache_exists || $memcached_exists) { ¶
    

    Extra space at EOL.

  15. +++ b/README.txt
    @@ -166,55 +169,133 @@ Memcache locks can be enabled through the services.yml file.
    +    // Bootstrap cache.container with memcache rather than database.
    

    s/rather than database/rather than the database

  16. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +Error:
    

    Likely redundant with the 'PROBLEM' string above. Perhaps we should rename PROBLEM in ERROR directly.

  17. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +Data in cache_config and other bins is stale after code updates and
    

    More text could fit in here, until we get to 80 cols.

  18. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +Drupal cache rebuilds. ¶
    

    Extra space at EOL.

  19. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +Drupal core sets static cache bins to use the fast chained backend ¶
    

    Extra space at EOL.

  20. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +so objects in static bins (cache_config, cache_discovery, cache_bootstrap) are ¶
    

    Extra space at EOL.

  21. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +since they are not yet set to expire. ¶
    

    Extra space at EOL.

  22. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +To override this behavior, set cache_config and other static caches
    

    You could use the space on this line until you get to 80 cols.

  23. +++ b/README.txt
    @@ -229,6 +310,27 @@ WARNING:
    +to use memcache as the backend prior setting memcache as the default backend: ¶
    

    Extra space at EOL.

lcatlett’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new20.58 KB

Updated patch is attached addressing the issues in #3

anavarre’s picture

Issue summary: View changes
StatusFileSize
new16.51 KB

An interdiff is helpful here.

volkswagenchick’s picture

Issue tags: +fldc18

I am tagging this fldc18 so I can use this issue as an example in a session for Florida Drupal Camp this weekend. Thanks!

volkswagenchick’s picture

Status: Needs review » Needs work

I used simplytest.me to review patch, it applies clean.

Some minor nitpicks to do with extra spaces.

  1. +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +    # Replaces the default persistent lock backend with memcache. ¶
    

    extra space at the end on line 170

  2. +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +  // Register required class namespaces. ¶
    

    extra space at the end of line 197

  3. +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +Since Drupal 8.2.x cache bins such as config, bootstrap, and discovery will ¶
    

    extra line at the end of line 256

  4. +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +  // Register required class namespaces. ¶
    

    extra space at the end of line 297

janusman’s picture

From https://www.drupal.org/files/issues/update-readme-2934916-4.patch ...

+++ b/README.txt
@@ -156,71 +161,209 @@ the default in this case but could be set using:
+$memcache_module_is_present = file_exists(DRUPAL_ROOT . '/modules/contrib/
+memcache/memcache.services.yml');
...
+    $class_loader->addPsr4('Drupal\\memcache\\', 'modules/contrib/
+    memcache/src');

These 2 sections in the patched README have newlines for readability, but that causes the actual code (if pasted as-is) to silently fail (e.g., $memcache_module_is_present would always be false) because of the newlines at the end of line 273 and 287 of the patch.

timodwhit’s picture

Nice work with the changes. Here are a few grammatical suggestions.

  • +++ b/README.txt
    @@ -24,20 +24,25 @@ These are the steps you need to take in order to use this software. Order
    + 4. If you wish to arbitrarily send cache bins to memcache such as cache_data
    

    "Arbitrarily" doesn't seem to fit here. Since there is most likely a strategy as mentioned in a later section. Maybe we reference that section

  • +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +core's streamlined bootstrap service container. Ensure that that the path in
    

    double that

  • +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +$class_load->addPsr4 is poiting to the right location of memcache such as
    

    poiting -> pointing

  • +++ b/README.txt
    @@ -156,71 +161,209 @@ the default in this case but could be set using:
    +Since Drupal 8.2.x cache bins such as config, bootstrap, and discovery will ¶
    

    I don't think the "Since" is needed here. But it might be good to provide more context on what moving these bins could help with.

  • webchick’s picture

    mpotter’s picture

    The problem I have with the entire method of dealing with memcache in settings.php is that the README instructions basically tells you to autoload memcache even if you have the module disabled.

    For one, this currently breaks Rules module.

    But I totally need to have a single deploy step for enabling Memcache. Seems like a simpler approach of loading the core.extensions.yml to see if memcache module is enabled would be less complicated.

    But yes, the current README instructions for memcache don't work and the patch fixes it (with the side effect of breaking Rules and who knows what else). But at least it doesn't cause the error when memcache module is disabled.

    mpotter’s picture

    For the Rules issue it seems the patch in #2816033: Rules registers no listeners on rare occasions. #33 might fix this. So maybe it's a Rules issue and not a Memcache issue. Although doing the autoloader in settings.php regardless of if memcache module is enabled still seems nasty.

    But given that webchick just marked this as a D8 stable blocker I guess I withdraw my complaint for now. Maybe someday we'll have a cleaner way of handling this.

    webchick’s picture

    Well, the stable blocker is specifically "make sure the README is up to date and gets you a working install," so if we need to document different things to avoid these kinds of errors, that can be part of it.

    misc’s picture

    I have been trying for almost one and a half years to be co-maintainer of this module to help out. No luck yet.

    wturrell’s picture

    Firstly, thanks to lcatlett and others for doing this; the info on memcache modules in blogposts etc. is inconsistent.

    I think it'd help to mention memcache_admin somewhere, given it has to be manually enabled and I discovered it by accident.

    Also, if anyone can help me set it up with Docker (Docker for Mac is rather slow; it feels like memcached might help) perhaps we should have a few lines about that. #2996656: Configuring for Lando/Docker

    anavarre’s picture

    It'd be great to move forward with updating the README file before tagging the GA. This would help with testing the RC and seeing if anything breaks.

    idebr’s picture

    Closed #2908413: Minor mistake of bullet numbering in README.txt as a duplicate issue, since these changes are included in the latest patch in this issue. Please credit @yas and @Disha.addweb for their work in the related issue.

    heddn’s picture

    Issue tags: +Needs reroll

    patch no longer applies.

    muldos’s picture

    Hi,
    I've just setup memcached on my project.
    Reading this patch was helpful, but I think recent code changes require to update the bootstrap container definition if we want it to use memcached.

    Here is what has worked for me :

      // Define custom bootstrap container definition to use Memcache for
      // cache.container.
      $settings['bootstrap_container_definition'] = [
        'parameters' => [],
        'services' => [
          'database' => [
            'class' => 'Drupal\Core\Database\Connection',
            'factory' => 'Drupal\Core\Database\Database::getConnection',
            'arguments' => ['default'],
          ],
          '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.backend.cache.container' => [
            'class' => 'Drupal\memcache\DrupalMemcacheInterface',
            'factory' => ['@memcache.factory', 'get'],
            'arguments' => ['container'],
          ],
          'cache_tags_provider.container' => [
            'class' => 'Drupal\Core\Cache\DatabaseCacheTagsChecksum',
            'arguments' => ['@database'],
          ],
          'cache.container' => [
            'class' => 'Drupal\memcache\MemcacheBackend',
            'arguments' => [
              'container',
              '@memcache.backend.cache.container',
              '@cache_tags_provider.container',
              '@memcache.timestamp.invalidator.bin',
            ],
          ],
        ],
      ];
    

    This is because now MemcacheBackend takes only 4 arguments in its constructor ( http://cgit.drupalcode.org/memcache/tree/src/MemcacheBackend.php?h=8.x-2.x)

    Another change I've spotted is stampede & lock configuration.

    To have it working properly, I've take example on http://cgit.drupalcode.org/memcache/tree/example.services.yml?h=8.x-2.x

      $settings['memcache']['stampede_protection'] = TRUE;
      $settings['container_yamls'][] = DRUPAL_ROOT . "/${site_path}/memcache-lock.services.yml";
    

    with memcache-lock.services.yml

    services:
      # Replaces the default lock backend with a memcache implementation.
      lock:
        class: Drupal\Core\Lock\LockBackendInterface
        factory: ['@memcache.lock.factory', get]
    
    jonathanshaw’s picture

    The readme is very confusing as it is now, especially to the non-expert in Memcache.

    It's hard to know what is the basic recommended approach, and what are advanced esoterica one can happily ignore if one doesn't know what they are.

    I suggest something like the following approach:

    Requirements: Memcache vs memcached (you need 1, but the module will auto-detect for you, method of configuration is different)
    Basic installation steps (assume module in installed first)
    Recommended settings (what 80% of people will be happy having in their settings.php)
    Advanced cache considerations (why/when/what might be varied from the recommendation)
    Settings for multiple sites
    Settings for multiple servers
    Advanced installation procedures (if module not installed first)
    Other advanced configuration

    keansmith’s picture

    PHP Memcache does not work for PHP 7.
    http://php.net/manual/en/book.memcache.php

    o'briat’s picture

    PHP memcache PECL support PHP 7 since 4.x (2019) en PHP8 since 8.0 (2020).

    This issue is totally outdated. Is the readme still need to be updated ?

    o'briat’s picture

    The LOCKS part is a bit messy :

    • There is no info about the possible include of example.services.yml
    • example.services.yml and the $settings['bootstrap_container_definition'] seems to overlap : memcache.timestamp.invalidator.tag is duplicated. cache_tags.invalidator.checksum and lock could be moved from services file to this array, no ? Maybe all the example.services.yml content could be moved here ?

    Charchil Khandelwal made their first commit to this issue’s fork.

    o'briat’s picture

    I just stumble on a memcached failover presentation on PHP doc :https://www.php.net/manual/fr/memcached.addservers.php#118940

    IMHO the failover should be more documented in the README: the advantages of this solution (perf and resiliency), what happen when a server is added or missing, ...