1000 FAQs, 500 tutorials and explanatory 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 Cloud Server.
Prerequisites
- Install Memcached on Managed Cloud Server.
Check Memcached is running
To check that Memcached is working properly:
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 "); 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; }
- Upload the PHP file to your hosting.
- Run the PHP file.
The script returns the number of elements cached in the server's memory.
Enable Memcached on…
… Prestashop
The native integration of Memcached in the Prestashop application simplifies its configuration. To activate it:
- Access your Prestashop admin space.
- Go to the Advanced Settings tab.
- Select Performances.
- Select Yes from the dropdown menu under Use cache in the Caching section.
- Select CacheMemcached.
- Add a server by providing the required information such as
- the IP address:
127.0.0.1
- the port:
11211
- the weight:
1
- the IP address:
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.