Skip to content

Gracefully fail when Redis commands fail #461

@danielvonmitschke

Description

@danielvonmitschke

Hi,

I am using redis-cache on a plesk server with a bitnami/redis docker container.

In my log file I get quite a few fatal errors in the form of Uncaught RedisException: read error on connection to 127.0.0.1:6379 in /var/www/vhosts/sites/www.web/app/object-cache.php:1897.

In your FAQ your write to just ignore there error and that would be total fine with me.

Unfortunately there is a "BUT":
I saw quite a few instances where this caused some basic wordpress or woocommerce "operations" to fail.
And in my opinion that should not be the case.

Here is what I mean with that:
We have some operation in wordpress or woocommerce that is trying to "do" something and in some place it uses caching or transients. Most of the time that would be just asking if there is some value in the cache and if not to do a costly calculation of this value.
But if there is a connection problem with redis this causes the whole operation to break.
Instead redis-cache should fail gracefully in this case and just behave as if the value wasn't present in the cache (e.g. return false or whatever the default value is for that).
This of course should be applied to all redis cache functions.
This way we wouldn't break any higher level operations just because the cache is not working for a split second.

Please let me know what you think.

Best,

daniel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions