Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Check Memcached

This guide explains how to manage Memcached and, in particular, how to check if this in-memory caching system is working correctly on your Managed Cloud Server.

 

Prerequisites

 

Check Memcached execution

To verify that Memcached is working correctly:

  1. Copy the following code into a PHP file:

    						// connexion au serveur memcache local		
    $fp = fsockopen("localhost", 11211);
    if ($fp) {
    // on demande les stats
    fwrite($fp, "stats\n");
    while (!feof($fp)) {
    $buf = rtrim(fgets($fp));
    if (preg_match('/^STAT curr_items ([0-9]+)$/', $buf, $matches)) {
    // le nombre d'items stockes
    print $matches[1] . PHP_EOL;
    } elseif (preg_match('/(END|ERROR)/', $buf)) {
    // fin des stats
    break;
    }
    }
    fclose($fp);
    } else {
    print "Error: cannot connect to local memcached server: $!" . PHP_EOL;
    }
  2. Upload the PHP file to your hosting.
  3. Run the PHP file.

The script returns the number of elements cached in the server's memory.

 

Activate Memcached on…

… Prestashop

The native integration of Memcached in the Prestashop application simplifies its configuration. To activate it:

  1. Access your Prestashop admin space.
  2. Go to the Advanced Settings tab.
  3. Select Performance.
  4. Choose Yes from the dropdown menu under Use cache in the Caching section.
  5. Select CacheMemcached.
  6. Add a server by providing the required information such as
    1. the IP address: 127.0.0.1
    2. the port: 11211
    3. the weight: 1

You can check the information by clicking the "Test server" button before saving it at the bottom of the "Caching" section.

Once this step is completed, your PrestaShop application is ready to use Memcached to cache certain API calls, database calls, and objects.


Has this FAQ been helpful?