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:
- Client software, which receives a list of available Memcached servers.
- A client-based hashing algorithm (which chooses a server based on the key input)
- Server software (Value stored with keys into internal hash table)
- 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:
- Path will be : /etc/memcached.conf.
- set 1GM for -m in configuration file
- 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 !!!