Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.
Configure Magento to use Memcached:
<your Magento install dir>/app/etc/env.phpin a text editor.
- Locate the following:
'session' => array ( 'save' => 'files', ),
3. Change it as follows:
'session' => array ( 'save' => 'memcache', 'save_path' => 'tcp://<memcache ip or host>:<memcache port>' ),
'session' => array ( 'save' => 'memcached', 'save_path' => '<memcache ip or host>:<memcache port>' ),
4. Continue with the next section.
Verify Memcached is Working with Magento 2
To check whether memcached works with your Magento 2 ecommerce stores or not, do the following steps:
1. Delete the contents of the following directories under your Magento installation directory:
rm -rf var/cache/* var/page_cache/* var/session/*
2. Go to any page on the storefront.
3. Log in to the Magento 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 [cci]env.php[/cci] has no syntax errors.
4. (Optional.) Use Telnet to look at memcached storage.
telnet <memcached host or ip> <memcached port> stats items
The results display similar to the following:
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
Hope this helps!