Skip to content
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

[Compatibility] Added GETEX command #695

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Vijay-Nirmal
Copy link
Contributor

@Vijay-Nirmal Vijay-Nirmal commented Sep 29, 2024

Adding GETEX command to garnet

  • Add GETEX command
  • Add Test cases
  • Add documentation

@TalZaccai TalZaccai self-requested a review October 1, 2024 18:22
Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, will finish the review later today :)

libs/server/Resp/BasicCommands.cs Outdated Show resolved Hide resolved
libs/server/Resp/BasicCommands.cs Outdated Show resolved Hide resolved
libs/server/Resp/BasicCommands.cs Outdated Show resolved Hide resolved
libs/server/API/IGarnetApi.cs Outdated Show resolved Hide resolved
libs/server/API/GarnetApi.cs Outdated Show resolved Hide resolved
@Vijay-Nirmal
Copy link
Contributor Author

Fixed the current review comments


if (input.ExtraMetadata > 0)
{
byte* pbOutput = stackalloc byte[ObjectOutputHeader.Size];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to call existing EvaluateExpireInPlace method but I don't care about the output param, so created a temp SpanByteAndMemory without any allocation and called the existing method

case RespCommand.GETEX:
CopyRespTo(ref value, ref output);

if (input.ExtraMetadata > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you check for !isPersist here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have to because if there is ExtraMetadata then that means the user has provided the expiration time so it can't be a Persist options, so there is no point in checking for !isPersist

}

oldValue.AsReadOnlySpan().CopyTo(newValue.AsSpan());
var isPersist = *(bool*)(inputPtr + RespInputHeader.Size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? If we're only doing GET + PERSIST, would we ever reach CopyUpdate?

Copy link
Contributor Author

@Vijay-Nirmal Vijay-Nirmal Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally not, add it just in case. I am doubting myself mainly because the existing PERSIST comment also has an entry in CopyUpdater. if you are sure then I can remove it. Shall I?

if (input.ExtraMetadata > 0)
{
Debug.Assert(newValue.Length == oldValue.Length + input.MetadataSize);
byte* pbOutput = stackalloc byte[ObjectOutputHeader.Size];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -185,6 +185,13 @@ public int GetRMWModifiedValueLength(ref SpanByte t, ref SpanByte input)
// No additional allocation needed.
break;

case RespCommand.GETEX:
if (input.ExtraMetadata > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this should always be true if we reach here? Could just do a Debug.Assert(input.ExtraMetadata > 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more comments...

@Vijay-Nirmal
Copy link
Contributor Author

@TalZaccai Fixed the review comments, there is one open question there.

Copy link
Contributor

@vazois vazois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a slot verification test in ClusterSlotVeficationTests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants