Cache Management for Beginner | How to configure Memcache in Magento2 | Part5

What is Memcache : Memcached is an open source distributed memory caching system. Memcached stores data based on key-pair values for small arbitrary strings or objects. Once the table is full, than the subsequent inserts cause older data to be purged in Least Recently Used order (LRU).

Components in memcache:

  1. Client software, which receives a list of available Memcached servers.
  2. A client-based hashing algorithm (which chooses a server based on the key input)
  3. Server software (Value stored with keys into internal hash table)
  4. Least Recently Used

Install Memcache:

  • >sudo apt-get -y update
  • >sudo apt-get -y install php5-memcache memcached

Note: Depend of the OS, the above command may change.

Memcache Configuration file path:

  1.  Path will be : /etc/memcached.conf.
  2.  set 1GM for -m in configuration file
  3.  service memcached start / service memcached restart / service memcached stop the memcache.

Configure Memcache in Magento :

  •  Open app/etc/env.php
  •  Comment out below code (or) remove it

  • Replace below code with above line,

Sample Code Snippet :

‘session’ =>

array (

‘save’ => ‘memcached’,

‘save_path’ => ‘tcp://<memcache IP or HOST>:<memcache PORT>’

),

Verify Memcache is working with magento2:

  •  Remove files from var/cache , var/page_cache & var/session
  •  Visit some frontend pages , in case if you are not getting any syntax error or xml error than the setup is done properly.

Check List of keys :

In general term there are no possible way to see the list of all the keys. But using below command we can able track the few list of keys using follow Command :

telnet <HOST> <PORT>

Ex: telnet 127.0.0.1 11211

Output :

stats items

STAT items:4:number 1

STAT items:4:age 498

STAT items:23:number 1

STAT items:23:age 498

END

WATER is LIFE !!! Don’t Waste It !!!