Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Avoid writing multiple keys when using redis in cluster mode #53940

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

bentleyo
Copy link
Contributor

This PR should prevent Redis failing with a "Error processing EXEC across the cluster" error when using Cache::flexible with Redis in cluster mode (#53266).

The problem is that open-source Redis doesn't allow commands that will update multiple "hash slots" (how Redis splits up keys). As far as I can tell this will only be an issue for Redis in cluster mode.

Redis has some info about this on their blog. See the "Redis Hashtags" section, in particular:

Open source Redis is quite strict about this and any command that manipulates multiple hash slots is forbidden. Redis Enterprise has a few workarounds for simple commands, notably MGET and MSET.

There is also a pre-existing issue for this problem that has been reported on phpredis: phpredis/phpredis#876

The issue there has existed since 2016 and the author of the extension suggests there may not have a path forwards due to limitations of Redis / complexity.

As such, I've opted to calling put multiple times when the connection is a cluster connection.

This isn't a pretty solution, but I'm not sure what else we can do.

@taylorotwell taylorotwell merged commit f349abb into laravel:11.x Dec 17, 2024
25 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants