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.
- Log in to cPanel.
- Scroll down and click on Select PHP Version.
- Make sure you switch to PHP Extensions.
- Find the tick box next to Memcached and ensure it is selected.
- If you are running WordPress, ensure you are logged in.
- Ensure that you are using LiteSpeed Cache plugin.
- Click the Advanced tab at the top of the screen.
- Ensure object cache is turned on.
- Under Method, select Memcached.
- 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.