Memcache, in our case, is a PHP module acting as a cache server. It is notably used to improve the response time of websites. Memcached on the WordPress side mainly uses the RAM of your hosting, and few CPUs. It saves objects such as API calls, page rendering and database call results in order to make these resources available more quickly.
You want to set up a caching system and you encounter an error similar to this one :
Fatal error: Uncaught Error: Class ‘Memcache’ not found in […]
Where does this error come from?
Most of the time this error is due to the lack of activation or support of the memcache extension (PHP) on your web server side.
It can also occur due to a problem with your WordPress installation.
Finally, it can occur for example following the restoration of a database or part of a previous database, on another hosting for example.
What can be done to solve this problem?
There is a way to “work around” the temporary problem, and a way to solve it.
If you choose to work around the problem, it will not give you the benefits of the memcache cache server. The goal here is to prevent the error from appearing while still keeping your website usable.
To simply “remove” this error:
If you have access to your database:
- If you have access to a recent backup of your database and that it does not involve a significant loss of data or of your last works, you can try to restore this backup before setting up the memcached cache
- To perform this operation, the easiest way is to connect to your database with your credentials and the right rights via a web interface provided by your host, or upload a recent version of phpMyAdmin on your site via (S)FTP : https://www.phpmyadmin.net/downloads/
If you don’t have access to your database (and you don’t want to install a client to access your database) :
- Connect to your site using (S)FTP
- Go to /wp-content
- Rename or (save and) delete the file object-cache.php
To solve this problem:
Contact your hosting provider to see with him the possibilities of activating the memcache extension for PHP. This will solve your error and you will be able to set up your cache solution to speed up your website.
Be aware that there are different caching solutions, various extensions for WordPress. Nevertheless, make sure to check the compatibility of your hosting according to the solution you choose and to set up these solutions if you want them to be efficient. Don’t hesitate to contact an expert in the field who can guide you towards the best solution for your website and help you configure this solution.