What is Memcached?

One question we often get asked at Peter’s Web is why should I use Memcached, or what is it in the first place?  The easiest way to explain what Memcached is, is to look at your typical WordPress site. In order to generate pages WordPress queries the database to receive data that it then converts into a web page. In computing terms, querying a database is a slow process, due to the fact that we very rarely require all of the data, so the database has to search for the relevant data and may have to talk to two or more tables in order to get one little bit of information.  This is where Memcached is excellent, once you have generated a page, Memcached will store the output of the query.  Meaning that the next time the same page is requested it can retrieved from the cache rather than querying the database. 

Memcached is made up of four key components:

The client software, which provides locations of where data can be stored

A client based hashing algorithm,  which scrambles the key which makes the storing of data easier. This is highly technical and would probably bore you to death.

Server software, stores the actual data on the server, and is available on all Peter’s Web accounts.

LRU (Last Recently Used), manages the storage of the Memcached by deleting those items not recently used.

Each of the four key components is comprised of a key, expiration time, and raw data.  A visitor to your site requests a webpage, which Memcached checks to see if it has been stored in the cache. If it is, the data is loaded from the cache, if not Memcache will need to check the database, subsequently taking longer to load. Whenever information is updated, the Memcached is updated to ensure clients receive up to date content.

This is how you activate Memcached.

  1. Log in to cPanel.
  2. Scroll down and click on Select PHP Version.
  3. Make sure you switch to PHP Extensions.
  4. Find the tick box next to Memcached and ensure it is selected.
  5. If you are running WordPress, ensure you are logged in.
  6. Ensure that you are using LiteSpeed Cache plugin.
  7. Click the Advanced tab at the top of the screen.
  8. Ensure object cache is turned on.
  9. Under Method, select Memcached.
  10. Leave the rest as standard and click save.

Please don’t hesitate to get in touch with us here at Peters Web should you require any more guidance on this topic. You can contact us via a support ticket (open a ticket) to our hosting department.

Powered by BetterDocs

Leave a Reply