[5.8] Add setDriver()#28985
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I'd like to change the Redis driver at runtime (in tests, to verify that a part of my package works both with predis and phpredis). I'm unable to do that because
RedisManagerseems to be a singleton whosedriverproperty can't be changed.Changing the
driverproperty onRedisManagershould allow to switch the connection driver. All methods for resolving connections use theconnector()method which returns a connector instance based on the value of thedriverproperty:framework/src/Illuminate/Redis/RedisManager.php
Lines 147 to 160 in 74b4267
I see that changing the Redis driver at runtime doesn't have much use in application code, unlike the database, because you can have multiple connections. However, it's impossible to test predis and phpredis support without this feature. If you don't want a setter, changing the visibility of the
driverproperty to a public would work as well.