Title: Fatal error: Cannot redeclare wp_cache_add()
Last modified: December 16, 2022

---

# Fatal error: Cannot redeclare wp_cache_add()

 *  Resolved [Razva](https://wordpress.org/support/users/razva/)
 * (@razva)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/)
 * Hey,
 * I’m getting this when trying to install your plugin:
 *     ```wp-block-code
       Fatal error: Cannot redeclare wp_cache_add() (previously declared in /home/plantemania/public_html/wp-includes/cache.php:41) in /home/plantemania/public_html/wp-content/plugins/object-cache.php on line 19
       ```
   
 * Please note that I have manually uploaded `object-cache.php` to `wp-content` 
   as recommended in the installation instructions.
 * I’ve also added `define( 'WP_CACHE_KEY_SALT', 'plantemania' );` in `wp-config.
   php`.
 * Yes, the PHP module is installed and the service is running:
 *     ```wp-block-code
       plantemania@server:~$ php -m | grep memcache
       memcached
   
       plantemania@server:~$ systemctl status memcached
       ● memcached.service - memcached daemon
            Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
            Active: active (running) since Fri 2022-12-16 08:58:34 EET; 32min ago
              Docs: man:memcached(1)
          Main PID: 1473014 (memcached)
             Tasks: 10 (limit: 4694)
            Memory: 29.6M
               CPU: 1.599s
            CGroup: /system.slice/memcached.service
                    └─1473014 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid
       plantemania@server:~$
       ```
   
 * Any way to fix this? Thank you
    -  This topic was modified 3 years, 5 months ago by [Razva](https://wordpress.org/support/users/razva/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Andrija Vučinić](https://wordpress.org/support/users/aidvu/)
 * (@aidvu)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16296083)
 * Hey,
 *     ```wp-block-code
       plantemania@server:~$ php -m | grep memcachememcached
       ```
   
 * So this isn’t the correct extension. It should return `memcache` not `memcacheD`.
 * As for the fatal:
 *     ```wp-block-code
       Fatal error: Cannot redeclare wp_cache_add() (previously declared in /home/plantemania/public_html/wp-includes/cache.php:41) in /home/plantemania/public_html/wp-content/plugins/object-cache.php on line 19
       ```
   
 * Did you by chance also install the plugin? If yes, uninstall and just copy `object-
   cache.php` to `wp-content`. No idea what the `wp-content/plugins/object-cache.
   php` file is (notice the `/plugins`).
 *  Thread Starter [Razva](https://wordpress.org/support/users/razva/)
 * (@razva)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16296885)
 * Hey,
 * I appreciate the fast reply.
 * As instructed I moved `object-cache.php` to from `wp-content/plugins` to `wp-
   content`. Here it is:
 *     ```wp-block-code
       $ ls ~/public_html/wp-content/
       index.php  languages  object-cache.php  plugins  smush-webp  themes  upgrade  uploads
       ```
   
 * Here’s the content’s of the `plugins` folder:
 *     ```wp-block-code
       $ ls ~/public_html/wp-content/plugins/
       contact-form-7  google-site-kit  js_composer  meta-box            meta-box-tabs       redux-framework  sumodiscounts  wordpress-seo
       envato-market   index.php        mailpoet     meta-box-show-hide  nt-agro-shortcodes  revslider        woocommerce    wp-smushit
       ```
   
 * The current result is `wp-admin` throwing `There has been a critical error on
   this website.`
 * I have uploaded a [simple PHP script](https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/storage/session-storage/memcache-ubuntu.html)
   to test if `memcache` is working and [it’s fully functional](https://plantemania.ro/memcachetest.php)(
   on the same page you can find a `phpinfo` that confirms that `memcache 3.2.0`
   is installed and fully functional).
 * Any hints on this?
 * Thank you!
 * **Later edit:** I can confirm that both W3 and LiteSpeedCache plugins can connect
   to the `memcache` server and enable the Object Cache function.
    -  This reply was modified 3 years, 5 months ago by [Razva](https://wordpress.org/support/users/razva/).
    -  This reply was modified 3 years, 5 months ago by [Razva](https://wordpress.org/support/users/razva/).
 *  Plugin Contributor [Andrija Vučinić](https://wordpress.org/support/users/aidvu/)
 * (@aidvu)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16297628)
 * > The current result is `wp-admin` throwing `There has been a critical error 
   > on this website.`
 * What does the PHP error log show for this now that you’ve moved the file?
 * > I have uploaded a [simple PHP script](https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/storage/session-storage/memcache-ubuntu.html)
   > to test if `memcache` is working and [it’s fully functional](https://plantemania.ro/memcachetest.php)(
   > on the same page you can find a `phpinfo` that confirms that `memcache 3.2.0`
   > is installed and fully functional).
 * This is what I’ve been trying to tell you. 🙂
 * There are two PECL extensions for memcached backend:
    - memcache – [https://pecl.php.net/package/memcache](https://pecl.php.net/package/memcache)–
      the one this plugin uses
    - memcached – [https://pecl.php.net/package/memcached](https://pecl.php.net/package/memcached)–
      the one you have, but is not supported
 * Hope that helps.
 *  Thread Starter [Razva](https://wordpress.org/support/users/razva/)
 * (@razva)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16298461)
 * Oh, ok, **sorry for my stupidity**! I’ve successfully installed `memcache`.
 * > For posterity, doing `apt install phpX-memcached` does not equal with `apt 
   > install phpX-memcache`.
 * The `Critical error` is not being displayed after installing the correct PECL
   extension.
 * Thank you for your patience and support!
 *  Plugin Contributor [Andrija Vučinić](https://wordpress.org/support/users/aidvu/)
 * (@aidvu)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16298573)
 * > Oh, ok, **sorry for my stupidity**! I’ve successfully installed `memcache`.
 * Don’t worry. 🙂 Glad it works now!
 * > Thank you for your patience and support!
 * <3

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Fatal error: Cannot redeclare wp_cache_add()’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/memcached.svg)
 * [Memcached Object Cache](https://wordpress.org/plugins/memcached/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/memcached/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/memcached/)
 * [Active Topics](https://wordpress.org/support/plugin/memcached/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/memcached/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/memcached/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Andrija Vučinić](https://wordpress.org/support/users/aidvu/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-error-cannot-redeclare-wp_cache_add-3/#post-16298573)
 * Status: resolved