So I have an update. I have discovered that the read error on connection
and page timeouts are not related. They are two separate issues which I will attempt to explain …
The page timeout / slow response is 100% related to using Predis rather than PHP Redis. After over two weeks of using https://hofnar.com with your plugin and PHP Redis (rather than Predis) we have had no page load issues at all and the site continues to load very quickly. We have also had no error notices in debug.log
. This leads me to believe that there is an issue in the way that Predis connects to Redis that does not present itself when PHP Redis is used instead. I would suggest that it may be worth setting your plugin to see if PHP Redis is available and if so use that as a default Redis connection rather than Predis. If you would like to undertake further testing to find out exactly what is causing the timeout when Predis is used, please let me know.
Now on to the cause of the read error on connection
notices which I can replicate by flushing the Redis cache or by disabling Redis using “Flush Cache” and “Disable Object Cache” buttons on your plugin’s settings page. Please note that this can be replicated when Predis or PHP Redis is being used.
This is caused because you are firing both actions on the load-settings_page_redis-cache
hook and when there is a large amount of cache data to flush this process takes longer on the Redis server than the rest of the page takes to load. This means that subsequent Redis requests on the same page load are not successful and a read error on connection
is resultant.
The fix for this would be to defer the flush-cache
and disable-cache
actions to the shutdown
hook. This would prevent cache requests from the current page load from failing and presenting the read error on connection
errors.
I have attempted to create a PR but you need to add me as a collaborator …
Pull request creation failed. Validation failed: must be a collaborator
My account on GitHub is webd-uk
Thank you,
Oliver