background img
Jan 28, 2019
0 0

How to use Memcached

Written by

One of the buy Pregabalin usa Memcached caching mechanisms that reside on your hosting server. Generally, this is related to doubly database queries that help reduce database load, resulting in a fast loading web page. If your website/store relies too much on database queries, using the mail code for the WordPress website will significantly improve performance and reduce page load time.

For example, internet giants including YouTube, Reddit, Facebook, Twitter, and Wikipedia are using Memcached to promote page load time. Google App Engine, Microsoft Azure, IBM Bluemix, and Amazon Web Services also provide this service through an API.

Considering its importance in increasing page load time, because we (Cloudways) offer pre-installed on our cloud servers. However, sometimes you may need to configure your application (WordPress) to take full advantage of the Memcached.

What is Memcached?

As a result in a simple word, it is a distributed floating object caching system that stores string and objects in the server’s RAM, resulting in the processing of database queries, API calls, or page rendering. The server used for this mechanism can call a memory server.

Memcached is used for whom?

its uses to reduce dynamic web applications such as e-commerce stores, registration/login websites, etc. Database load. It stores the processed results so that whenever a visitor requests the same query again, then the Memcached can respond instead of answering that query. By keeping the server free-busy, your visitors will experience faster loading times and better user experience.

How Does It Work?

Whenever a visitor/browser requests a server that requires processing and responding to the database, it adds a load to the server. By storing data objects in a temporary dynamic memory, the Memcached reduces the load. It saves data on key-values and checks its memory before sending the browser’s request to the database. If a cache is present, then it responds to the request without including the process.

As discussed above, it is a distributed memory object caching system that has four major components:

  • Client software: Receives a list of distributed available memory servers.
  • Client-based hashing algorithm: Then elects the server based on key-values.
  • Server software: stores data (values) and keys in the internal hashes table.
  • Server algorithms recognize when old data remove and reuse of memory.

The above-mentioned components allow Memcached to store and retrieve data. Each item includes:

  • Key
  • Expiry time
  • Raw data

When an item is requested, then the Memcached verifies its end time to see if the item is still valid before answering the request. If no cache exists, then it sends a request to process the database as an item and store it as an item.

The server is out of memory, then it looks and changes the finished item. If it still requires any information, then it searches for the requested items for a particular period. By this, Memcached keeps the information requested recently in dynamic memory.

In a high level of low-level Memcached work:

  1. Checks the requested data as reconfigured when stored in the cache.
  2. Two potential outputs:
    – The data is store in the cache: Return the requested data from the Memcached without interrupting the database.
    – The data is not stored in the cache: execute the requested query, process and recover the data, and save the result to the memory.
  3. Whenever an item update on an item, or an item expires, then the Memcached updates its cache and ensures that fresh content is a supplier to the customer request.

How to use Memcached?

There are two steps involved in using Memcached. First of all, it should be installed on your hosting server and then be able to support your application’s Memcached.

The installation and configuration process is In brief below:

Memory installed on the server

Memcached does not require much CPU resources. It is completely dependent on RAM. If you have a web server of 8GB RAM, but the OS and your websites only consume 4GB, then assigning the rest of the RAM in Memcached instances is a good idea to increase your storage capacity.

It works on mostly Linux-base servers, installing Memcached is only one to two Linux commands. Generally, you should install a Memcached package provided by your OS (Debian, Ubuntu, etc.) The operating system will resolve the dependency for you and will take care of the security updates.

For Debian or Ubuntu Users:


 apt-get install memkched 

For Redhat / Fedora:


Yum installed memory

It is notable that Nginx comes with one of the most popular reverse-proxy servers, with a Memcached module which provides the most flexible Nginx Memcached bundle solution.

Check if the Memcached is going on

If there is a running Memcached then there are several ways to test. Generally, one of them is using Telnet, log in to your server’s SSH terminal, and type it under the command:


telnet localhost 11211



telnet 11211

P.S: This command will run if the local server is your Memcached server.

If this command runs successfully, you will get the below result:

Connected to localhost.
Escape character is '^]'.

Otherwise, you will get a connection error.

Then you can use under the command to check some basic statistics:


You’ll find something like:

STAT pid 313
STAT uptime 2778636
STAT time 1535727399
STAT version 1.4.21
STAT libevent 2.0.21-stable
STAT pointer_size 64
STAT rusage_user 47.119322
STAT rusage_system 48.765342
STAT curr_connections 1
STAT total_connections 151198
STAT connection_structures 3
STAT reserved_fds 20
STAT cmd_get 46
STAT cmd_set 4
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 30
STAT get_misses 16
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 22942
STAT bytes_written 3433252
STAT limit_maxbytes 268435456
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT malloc_fails 0
STAT bytes 106
STAT curr_items 1
STAT total_items 4
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT lrutail_reflocked 0

To check the items, use:

stats items


STAT items:2:number 1
STAT items:2:age 2486
STAT items:2:evicted 0
STAT items:2:evicted_nonzero 0
STAT items:2:evicted_time 0
STAT items:2:outofmemory 0
STAT items:2:tailrepairs 0
STAT items:2:reclaimed 0
STAT items:2:expired_unfetched 0
STAT items:2:evicted_unfetched 0
STAT items:2:crawler_reclaimed 0
STAT items:2:lrutail_reflocked 0

To check current memory statistics write:

stats slabs


STAT 2:chunk_size 120
STAT 2:chunks_per_page 8738
STAT 2:total_pages 1
STAT 2:total_chunks 8738
STAT 2:used_chunks 1
STAT 2:free_chunks 8737
STAT 2:free_chunks_end 0
STAT 2:mem_requested 106
STAT 2:get_hits 30
STAT 2:cmd_set 4
STAT 2:delete_hits 0
STAT 2:incr_hits 0
STAT 2:decr_hits 0
STAT 2:cas_hits 0
STAT 2:cas_badval 0
STAT 2:touch_hits 0
STAT active_slabs 1
STAT total_malloced 1048560

To leave connection type quitAnd press Enter.

There is a list of some useful commands for running and monitoring of the servers, which are called here Can be seen.

Meme for cloud users

similarly, Cloudways users do not have to worry about all the technical issues related to Memcached WordPress. In the same way, all the servers launch on the Cloudways Platform have been pre-install and activate Memcached.

Navigate to your respective Manage Server → Services and you can see Memcached is pre-installed and activated by default.

WordPress Memkit Plugin

A lot of WordPress cache plugins are available on the market. Most of them support mail cards like W3TC, one of the most widely used cache plugins allows you to configure. If you are one of the W3TC users, go to the General Settings tab and select the Memcached from the dropdown, where it says:

  • Page cache
  • Shorten the cache
  • Database cache

Save all the settings and do not forget to purify the cache once.

We hope this article has been very helpful to you. If you like it, you can share it on the social network. If you have any queries, ask them in the comment box. Feel free to share your feedback!


Click me to find More Tips and Trick Here


Article Categories:
Plugins · WordPress Tricks and Tips

Leave a Reply

Your email address will not be published. Required fields are marked *

The maximum upload file size: 512 MB. You can upload: image, audio, video, document, text, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here