pj-object-cache-red icon indicating copy to clipboard operation
pj-object-cache-red copied to clipboard

Cannot redeclare wp_cache_add()

Open macdabby opened this issue 5 years ago • 3 comments

I just installed and got this error ....

Fatal error: Cannot redeclare wp_cache_add() (previously declared in /www-wordpress/tit/wp-includes/cache.php:30) in /www-wordpress/tit/wp-content/plugins/pj-object-cache-red/object-cache.php on line 35

macdabby avatar Nov 20 '20 14:11 macdabby

You have to follow the installation instructions. Object Caching plugins in WordPress should not be installed and activated as a plugin. The object-cache.php file from this repository has to be copied into wp-content/object-cache.php.

That said you bring up a valid point, installing it as a plugin should break the site with a non-fatal error, a warning that makes more sense and explains to check the readme.txt.

Thanks.

soulseekah avatar Nov 20 '20 14:11 soulseekah

I followed the directions and it looks like it's working now. I'm looking in that directory and i see that rocket-cache has installed some files in that directory, but we did not do anything i the filesystem. maybe this can be updated to work as a module and copy this object-cache.php into place on activation to make this more maintainable. also it would be great to be able to configure the server and prefix from the plugin. i guess this is now a feature suggestion instead of a bug report.

macdabby avatar Nov 20 '20 15:11 macdabby

Thanks. This object cache dropin is meant to be very very lightweight and portable. We will probably not consider adding any sort of settings screens in wp-admin, installers, etc.

Object caching is not meant for regular users as there are many pitfalls and sometimes object caching makes things work. We prefer to maintain a threshold to using our solution in a highly surgical manner.

Things may change in the future. I heard some of the more popular plugins are implementing the revolutionary idea of cache preloading in their own plugins. I think WP Rocket is one. I think they have it in the Pro version :)

Either way thanks for the error report, we should definitely not be crashing.

In terms of configuration in wp-config.php specify WP_REDIS_BACKEND_HOST, WP_REDIS_BACKEND_PORT, and WP_REDIS_BACKEND_DB to set the necessary, non-default connection values for your Redis instance.

Hope this helps.

Nice car.

soulseekah avatar Nov 20 '20 15:11 soulseekah