1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Check Memcached
This guide explains how to manage Memcached and particularly how to determine if this memory caching system is functioning correctly on your hosting.
Prerequisites
- install Memcached on Managed Cloud Server
Check Memcached Execution
To verify Memcached is running correctly:
Copy the following code into a PHP file:
// connect to the local memcache server $fp = fsockopen("localhost", 11211); if ($fp) { // request stats fwrite($fp, "stats\n"); while (!feof($fp)) { $buf = rtrim(fgets($fp)); if (preg_match('/^STAT curr_items ([0-9]+)$/', $buf, $matches)) { // number of stored items print $matches[1] . PHP_EOL; } elseif (preg_match('/(END|ERROR)/', $buf)) { // end of stats break; } } fclose($fp); } else { print "Error: cannot connect to local memcached server: $!" . PHP_EOL; }
- Upload the PHP file to your hosting
- Execute the PHP file
The script will return the number of items cached in the server's memory.
Enable Memcached on a CMS
Prestashop
The native integration of Memcached into the Prestashop application simplifies its configuration. To enable it:
- Access your Prestashop admin area
- Go to the Advanced settings tab
- Select Performance
- Choose Yes from the dropdown under Use cache in the Cache section
- Select CacheMemcached
- Add a server by providing the required information such as
- IP address:
127.0.0.1
- Port:
11211
- Weight:
1
- IP address:
You can test the information by clicking the "Test server" button before saving it at the bottom of the "Cache" section.
Once this step is completed, your PrestaShop application is ready to use Memcached to cache certain API calls, database calls, and objects.