-
Notifications
You must be signed in to change notification settings - Fork 694
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
Some issues about the GET parameter in the SET command #1415
Comments
Yes, in IFEQ we discussed forbidding the combination of GET with IFEQ, but we decided to add it in the same way as already exists for XX and NX. It would make the syntax more complex if we want to forbid this combination, but I think almost nobody will use it.
|
It seems like some users actually want to use SET NX GET. Here someone wanted to add it in KeyDB: Snapchat/KeyDB#415 |
It's better if no one is using it, so we can prohibit such usage, but things are usually not that simple. I think that since this usage is allowed, both the behavior and the results should be clear and definitive. However, the current mixing of I'm thinking that we could even introduce a new command, such as |
IMO a new command will create even more possibilities and more confusion. I think it's better to just use two commands GET and SET in a pipeline. Let's describe clearly in the beginning of the docs for SET something like this? Normal usage is just |
I also would prefer we not introduce a SET2. |
We should document it: If |
Sorry, but I find the new wording in the documentation confusing, since, as @zuiderkwast pointed out above (#1415 (comment)), GET + NX/XX are usable and one can determine from the result whether the "SET" was successful. But now, the documentation says My "mental model" of e.g. NX + GET is
So, if the result is If it isn't Am I missing a corner case here? |
When we updated the documentation, I wanted to add the word "alone". Yes, the user can determine if the command succeeded, but not from the reply alone. The client also needs to also consider which options were used in the command. The client can use this pseudo-code to find out if it was success or fail:
|
While this is technically true, isn't this a little bit subtle? (especially without further explanation) What if we transform part of your pseudo code into the following documentation note? (to be added to the GET option) Note: When using
|
Sure, can you open a doc PR? |
SET key value [ nx | xx ] [ get ] [ EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | keepttl ]
The usage of the SET command has become quite complex, as shown above. There are also some conflicts and ambiguities, particularly regarding the use of
GET
parameters and its reply. This complexity has also made it difficult for us to add new parameters, such asIFEQ
in #1324.Here are some examples:
NX
parameter and the situation when it is used together withGET
1.1 The situation of using
NX
onlyThe result is clear: "OK" indicates successful, while "nil" indicates failure.
1.2 The scenario of using
NX
withGET
togetherAt this point, the client is unable to determine based on the result whether the
SET
operation was successful. Does "nil" indicate that theNX
operation failed, or is it the value retrieved by theGET
operation?The current code retrieves the value using
GET
, but we still cannot confirm whether theSET
operation was successful (although it actually is).XX
parameter and the situation when it is used together withGET
2.1 The situation of using
NX
onlyThe result is clear: "OK" indicates successful, while "nil" indicates failure.
2.2 The scenario of using
NX
withGET
togetherSimilar to
NX
, we cannot determine the success ofSET
based on the results.The text was updated successfully, but these errors were encountered: