rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
427 stars 149 forks source link

Addition of custom options hook/filters #433

Closed damsean102 closed 1 year ago

damsean102 commented 1 year ago

Hi,

I was just wondering if there was any plans/thought about introducing a hook/filter to allow other developers the ability to define the settings that can be used here?

The reason I ask is that a need has arose for us to connect to REDIS via TLS and where our REDIS server is hosted (Heroku) requires us to alter some of the SSL parameters (verify_peer & verify_peer_name) which currently isn't possible using the plugin. I realise this is a feature of Object Cache Pro, but I was wondering if it is likely to make it's way to the free version or not?

Thanks in advance, Sam

tillkruss commented 1 year ago

Hey Sam, you can't use filters, because object-cache.php is loaded way before you can register them. We can add a new WP_REDIS_? constant tho to disable TLS verification.

You'd just need to ensure it works for PhpRedis as well as Predis. They do that differently.

damsean102 commented 1 year ago

Hi Till,

Thanks for the speedy reply! Yeah good point about the hooks, a constant could work well though. Something like WP_REDIS_TLS or something more generic (WP_REDIS_CONFIG) where we can pass client appropriate parameters into the Redis or Predis classes would be great.

I can spin up a new REDIS instance and test both those is that helps?

Thanks

tillkruss commented 1 year ago

Yup sounds good 👍

david-donachie commented 1 year ago

And here I am just sending you an email about the exact same issue! We are stuck in the same issue, where we can't connect to Heroku's self-signed Redis because we can't pass those SSL parameters. Since Heroku will force the upgrade by the 24th of April, this is pretty urgent for us.

Anything we can do to help?

tillkruss commented 1 year ago

You might be able to send the TLS parameters when using Predis.

david-donachie commented 1 year ago

You might be able to send the TLS parameters when using Predis.

Not sure I understand? Do you mean that the SSL parameters might be read by Predis from somewhere external to the Wordpress configuration?

tillkruss commented 1 year ago

As mentioned by email, Object Cache Pro fully supports TLS and configuration of it.

If you want to open a PR with TLS and it's options for Predis+PhpRedis we gladly merge it.

david-donachie commented 1 year ago

If you want to open a PR with TLS and it's options for Predis+PhpRedis we gladly merge it.

PR created. I went with the simplest possible setting of SSL parameters to work around the issue.