-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
mGet return false when no keys are provided #1810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@yatsukhnenko The |
@yatsukhnenko I would expect that requirement to be enforced somehow (with an exception, for instance) |
@greg0ire this will be breaking change and we can't do it until next major release |
Sure! I'm not in a hurry ;) |
I'm not sure about this change. @greg0ire why do you think that returning correct response on incorrect request is right behaviour? |
If by "correct response", you mean |
I think what @yatsukhnenko is saying is that 127.0.0.1:6379> mget
(error) ERR wrong number of arguments for 'mget' command Phpredis is identifying this and avoiding a round trip to the server. That said I'm not opposed to just returning an empty array here but like Pavlo mentioned it would be a breaking change so it has to wait until PhpRedis 6. |
I'm not suggesting you return an empty array, I'm suggesting you throw an exception, which would make the signature of mget be |
@greg0ire json_decode throws exception because it may return false/null is success and failure cases which doesn't allow to identify error. In phpredis we don't have this problem and use false may definetly identify error. Also I think that simple compare to false is better to read and understand than wrapping code to try/catch blocks |
@yatsukhnenko It might be easier but you will allow an incorrect behaviour, as the exception is thrown because the user tries to |
It is indeed simpler! The thing is, that kind of exception is not meant to be caught, and should instead result in a rewrite of the calling code, just like @dFayet and I rewrote our code today to avoid calling |
This should be revisited because the signature is now |
Line 2178 in 62cf943
|
Expected behaviour
According to the
mGet
doc:I expect to receive an
array
in any cases (as long as the keys parameter is an array)Actual behaviour
If I give an empty
array
tomGet
the return will befalse
I'm seeing this behaviour on
Have a good day.
The text was updated successfully, but these errors were encountered: