[9.x] Make sure the prefix override behaviours are the same between phpredis and predis drivers #42279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Yesterday I was doing research for the company (mainly to do with Redis prefix options) and I found that there are two problems with the implementation of the
\Illuminate\Redis\Connectors\PhpRedisConnector::connect
method.The first issue is that we use
Arr::pull
to pull the options from the config array, like so:The issue with this code is that the
Arr::pull
won't take effect and the final array from the array_merge will contain theoptions
key, as I can show you here in a simple dd snippet:The output is
This PR will make sure that we pull out the options key from the config so that we don't merge it into the final array. This is merely just a DX touch.
Secondly, I found that in the
\Illuminate\Redis\Connectors\PredisConnector::connect
method, we have the code to override the prefix inside theoptions
key of each redis config with the config's prefix key itself.This means for predis driver, the prefix for this config will be
config_
:However, if you use phpredis driver, the prefix that will be used in the connector is
config_options_
.This PR makes sure that the prefix override behaviour of the phpredis is working in the same way with the predis connector. This means such config would resolves in the prefix =
config_
.