l3rady / object-cache-apcu

46 stars 17 forks source link

documentation about WP_APCU_KEY_SALT #9

Closed Cyrille37 closed 2 months ago

Cyrille37 commented 4 years ago

Hello, Thank you for this extension that makes wordpress greener (and faster) !

I think the docu on WP_APCU_KEY_SALT is wrong because we need to define WP_APCU_KEY_SALT not only when sharing a wp-config.php but when we share a Php instance (mutualized php). Like with php-fpm, the APC memory is shared with all pools so we have to define a unique WP_APCU_KEY_SALT for each wordpress installation.

So the documentation may be : If you have more than one Wordpress installation which share the same Php you have to define a unique WP_APCU_KEY_SALT for each.

Thanks again and cheers :-) Cyrille37.

Cyrille37 commented 3 years ago

Hello. Is my comment wrong or confirmed ? Thanks & cheers

matt-h commented 2 years ago

This has salt based on the ABSPATH of the site so WP_APCU_KEY_SALT is needed only if more than one WordPress site is using the same directory on the server.

Cyrille37 commented 2 years ago

Yeah! Thanks, that's nice :-) But the README has to be updated, isn't it ? Best Regards.

kevin25 commented 1 year ago

So should we define something like define( 'WP_APCU_KEY_SALT', 'somethinghere' );, right?

kevin25 commented 1 year ago

And does it support WooCommerce?

docjojo commented 3 months ago

where do I have to define the WP_APCU_KEY_SALT ? in object-cache.php or in a plugin? if i define it in a plugin, it would only be available once the plugin is loaded IOW plugins and other functions loaded before this plugin would not have the the constant.

matt-h commented 3 months ago

where do I have to define the WP_APCU_KEY_SALT ? in object-cache.php or in a plugin? if i define it in a plugin, it would only be available once the plugin is loaded IOW plugins and other functions loaded before this plugin would not have the the constant.

You would put it in your wp-config.php file.

docjojo commented 3 months ago

makes sense.

l3rady commented 3 months ago

WP_APCU_KEY_SALT is not required to be set anywhere. If you don't understand what it is for then you likely don't need it

docjojo commented 3 months ago

I see, in my case ABSPATH differs for multiple WP installation on the same machine, so WP_APCU_KEY_SALT is not required?

l3rady commented 3 months ago

Correct. It is only need in very rare edge cases when someone is running multiple WP sites from a single set of core WP files. I don't know of anyone that does this so the default WP_APCU_KEY_SALT is fine.

docjojo commented 3 months ago

thank you.

docjojo commented 2 months ago

sorry for asking again.

I have a machine with multiple WP installations. Each install is in it's own directory, so ABSPATH differ. But in object-cache.php WP_APCU_KEY_SALT is defined with "wp", not ABSPATH, so all installations are using the same salt, no?

Code says:

` if (!defined('WP_APCU_KEY_SALT')) { /**

l3rady commented 2 months ago

https://github.com/l3rady/object-cache-apcu/blob/main/object-cache.php#L1120

Key uniqueness is made from an md5 of abs path. As long as your ABSPATH differ between installs on the same machine the keys wont clash. WP_APCU_KEY_SALT only needs to be changed if all installations share the same physical set of WP files.

docjojo commented 2 months ago

THANK YOU!