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

feat(set_family): Add support for KEEPTTL to SAddEx #4712

Merged
merged 5 commits into from
Mar 6, 2025

Conversation

abhijat
Copy link
Contributor

@abhijat abhijat commented Mar 6, 2025

Support is added for KEEPTTL to the SAddEx command as described in #4701

Arg parsing is done by parser in SAddEx. A test is added to check
invalid expiry handling.
When KEEPTTL is supplied with args, any existing keys in the set will
preserve their TTL values. Only new members will get TTL applied to
them.
@abhijat abhijat force-pushed the abhijat/feat/add_keepttl_to_saddex branch from d83147c to 210fc76 Compare March 6, 2025 12:15
constexpr uint32_t kMaxTtl = (1UL << 26);
CmdArgParser parser(args);

auto key = parser.Next<std::string_view>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

remember to use explicit types for simple types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@abhijat abhijat changed the title [wip] featset_family): Add support for KEEPTTL to SAddEx feat(set_family): Add support for KEEPTTL to SAddEx Mar 6, 2025
@abhijat abhijat requested a review from adiholden March 6, 2025 12:36

// KEEPTTL support. add field orig with TTL=10
EXPECT_THAT(Run({"saddex", "key", "10", "orig"}), IntArg(1));
// add fields new and orig with TTL=5 and KEEPTTL=true. orig ttl should be preserved
Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment says ttl=5 but in this command I see ttl=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I mixed up the comments, updated now.

EXPECT_THAT(Run({"saddex", "key", "10", "orig"}), IntArg(1));
// add fields new and orig with TTL=5 and KEEPTTL=true. orig ttl should be preserved
EXPECT_THAT(Run({"saddex", "key", "KEEPTTL", "1", "orig", "new"}), IntArg(1));
EXPECT_GT(CheckedInt({"fieldttl", "key", "orig"}), 5);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am confused, why is the fieldttl here is not 10?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also lets check the CheckedInt({"fieldttl", "key", "new"}) which should be set to 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am confused, why is the fieldttl here is not 10?

Oh you are checking EXPECT_GT I now understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, since some time passed since we set it to 10, I used 5 as an approximation to compare, so the test isn't flaky.

also lets check the CheckedInt({"fieldttl", "key", "new"}) which should be set to 1

Good point, added EXPECT_LE for 1.

@adiholden
Copy link
Collaborator

please also update our documentaion for the command here - https://github.com/dragonflydb/documentation

@abhijat abhijat requested a review from adiholden March 6, 2025 14:58
@abhijat abhijat merged commit 5f2dbb7 into main Mar 6, 2025
10 checks passed
@abhijat abhijat deleted the abhijat/feat/add_keepttl_to_saddex branch March 6, 2025 15:39
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.

None yet

2 participants