PHP 7.3 reaches end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in April 2022. You may want to consider planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.

Configure Commerce or Magento to use memcached

To configure Magento to use memcached:

  1. Open <your Magento install dir>/app/etc/env.php in a text editor.
  2. Locate the following:

    1
    2
    3
    4
    
    'session' =>
        array (
        'save' => 'files',
    ),
    
  3. Change it as follows:

    1
    2
    3
    4
    5
    
    'session' =>
        array (
          'save' => 'memcached',
          'save_path' => '<memcache ip or host>:<memcache port>'
    ),
    

    memcached has an optional startup parameters that are beyond the scope of this guide. You can find more information about them in the memcached documentation, source code, and changelogs.

  4. Continue with the next section.

Verify memcached is working with Magento

To verify memcached works with Magento:

  1. Delete the contents of the following directories under your Magento installation directory:

    1
    
    rm -rf var/cache/* var/page_cache/* var/session/*
    
  2. Go to any page on the storefront.

  3. Log in to the Admin and browse to several pages.

    If no errors display, congratulations! memcached is working! You can optionally look at memcached storage as discussed in the next step.

    If errors display (such as an HTTP 500 (Internal Server Error)), enable developer mode and diagnose the issue. Make sure memcached is running, configured properly, and that env.php has no syntax errors.

  4. (Optional.) Use Telnet to look at memcached storage.

    1
    
    telnet <memcached host or ip> <memcached port>
    
    1
    
    stats items
    

    The results display similar to the following:

    ```terminal STAT items:3:number 1 STAT items:3:age 7714 STAT items:3:evicted 0 STAT items:3:evicted_nonzero 0 STAT items:3:evicted_time 0 STAT items:3:outofmemory 0 STAT items:3:tailrepairs 0

    Look at the keys in more detail