This tutorial covers the following topics:
This tutorial explains how to configure your Magento 1.x or 2.x application to use Memcached. Both Magento versions natively support Memcached. This means that you just need to enable this option.
Enable Memcached for Magento 1.x
In order to do this you have to edit the Magento XML configuration file - local.xml. This file is stored inside the app/etc folder of the application. Open the file and find the following line of code which is usually at the end of the file:
Right before this line add the following ones:
<!-- apc / memcached / empty=file -->
<!-- memcached cache backend related config -->
<!-- any number of server nodes can be included -->
Note that you should replace the port in the "CDATA" line with the correct port number for your hosting account. For details on how to find out the correct port you can check this tutorial.
Once you are ready with the changes to the file - save it to apply the changes. That's it - your Magento 1.x application is now configured to use Memcached.
Enable Memcached for Magento 2.x
To configure your Magento 2.x to work with Memcached you need to add Memcached configuration in the application's env.php file. In this file, you will find a large number of PHP arrays with different other configurations and settings. Open your Magento root folder -> app -> etc > env.php and locate the following:
'save' => 'db',
Change the above code to:
'save' => 'memcached',
'save_path' => '127.0.0.1:memcached_port',
where memcached_port is the port used by the Memcached service for your account. For details on how to find out the correct port you can check this tutorial.
Once you are ready with the changes to the file - save it to apply the changes. That's it - your Magento 2.x application is now configured to use Memcached.