laravel / ideas

Issues board used for Laravel internals discussions.
940 stars 28 forks source link

phpredis vs predis lazy connect #1869

Open GrahamCampbell opened 5 years ago

GrahamCampbell commented 5 years ago

Description:

The laravel phpredis connector seems to connect to redis straight away, but the predis connector does not. It would be good if the phpredis one was also lazy when it comes to connecting to redis.

GrahamCampbell commented 5 years ago

Not sure if this is even feasable, but it's super annoying now that a bunch of my tests are now failing because redis is not available. For context, these tests are checking that I can resolve some classes from the IOC, which in turn causes the IOC to resolve the redis connection, which now tries to connect to the db, but before, with predis, it wouldn't try to connect.

GrahamCampbell commented 5 years ago

Not sure if this is even feasable

In a way that won't break code that messes with the internals of the connectors, that is.

driesvints commented 5 years ago

Heya. I transfered this to the ideas repo since nothing is really broken atm. Feel free to send in a pr if you can solve this without breaking BC.

mfn commented 5 years ago

That's an interesting issue.

The way I understand phpredis does not support this feature right?

I has something regarding "lazy_connect" but that seems to be concerned with RedisArray only => https://github.com/phpredis/phpredis/blob/develop/arrays.markdown#specifying-the-lazy_connect-parameter

Support for it in Laravel could only be done by a proxy object then I guess .. 🤷‍♀️

peterfox commented 5 years ago

Noticed this the other day and had to rewrite a few things in a project to use RedisManager and then grab the connection, was a bit of a pain. I imagine this could be solved with not initialising the client until a command is called for and then have a callable build the client.