Activate and test memcached in cPanel

Article in English Articol în Română

You can benefit from increased site load speed if you use object caching using the memcached module which is active on all web hosting and reseller hosting packages.

The first step is to check if the memcached module is enabled, for this go to cPanel > Select Php Version> Modules and check that it is checked.

Now to make sure that the memcached module works we can do the following:

Create a php file with the phpinfo(); function and load the page in your browser. On the page we will look for the memcached module that should look like this:

Another way we can verify that the memcached module works is to create a php file with the following code

<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
$mem = new memcached();
$mem->addServer("127.0.0.1",11211);
$result = $mem->get("Test");
if ($result) {
        echo $result;
} else {
echo "Test key not found, adding... Reload page.";
$mem->set("Test", "We found the key, memcached is working") or die("It did not work...");
}
?>

Then acces the file in the browser and it will tell you Test key not found, adding... Reload page, after which you must reload the page and receive the following message We found the key, memcached is working. This means that the key has been added to the memcached cache server and it was found.

Now that memcached is active and working, you can use it in the desired application.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)