-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added support for GET in SET command #246
Changes from all commits
f773350
d1766b2
9045f21
2d26c4d
77e926e
9fc1361
15a4584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,15 @@ func evalSET(args []string) []byte { | |
if obj != nil { | ||
return RESP_NIL | ||
} | ||
case "GET": | ||
obj := Get(key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just call evalGET() method before the value has been updated and return the o/p of evalGET() as is. wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so, like, I've to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @soumya-codes , I've a doubt, that since by using the So, first, we've to push the key to an array and then pass it to the |
||
|
||
if obj == nil { | ||
return RESP_NIL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it is better to just update the response here. Let us invoke PUT at just one place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. We don't have to call PUT in 2 places. Passing GET will just change the return value of the SET command. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, actually, previously I did by using Put in the end only, but there was a review from someone which mentioned that the value won't get updated if I didn't add Put at 2 places, this comment. NVM, I'll make the changes 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need to add Put in two places but you will need a variable for a response and then you can return that in the end if it was of subtype GET instead of RESP_OK. If you just return it from here only then PUT never gets called and SET command doesn't execute. That is what I meant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey! srivastav-yash, apologies for the miscommunication. Now I have got your point. But, actually, before doing that, I'm first trying to fix the issue with XX and NX options. If we're giving both xx and get, then the tests are failing. |
||
} | ||
|
||
// Return the RESP encoded value | ||
return Encode(obj.Value, false) | ||
yaten2302 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default: | ||
return Encode(errors.New("ERR syntax error"), false) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are adding GET, we cannot now blindly return from XX and NX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm not able to get it completely, could you please elaborate more on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @soumya-codes , I was just now running the tests with the
XX
option with theGET
one. The test is failing. I think do we need to change the completeevalSET()
func? I'm thinking of an approach for this, will update soon about it here 👍