-
Notifications
You must be signed in to change notification settings - Fork 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
feat(set_family): Add support for KEEPTTL to SAddEx #4712
Conversation
Arg parsing is done by parser in SAddEx. A test is added to check invalid expiry handling.
b2b4823
to
d83147c
Compare
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.
d83147c
to
210fc76
Compare
src/server/set_family.cc
Outdated
constexpr uint32_t kMaxTtl = (1UL << 26); | ||
CmdArgParser parser(args); | ||
|
||
auto key = parser.Next<std::string_view>(); |
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.
remember to use explicit types for simple types
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.
fixed
src/server/set_family_test.cc
Outdated
|
||
// 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 |
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.
the comment says ttl=5 but in this command I see ttl=1
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.
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); |
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.
I am confused, why is the fieldttl here is not 10?
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.
also lets check the CheckedInt({"fieldttl", "key", "new"}) which should be set to 1
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.
I am confused, why is the fieldttl here is not 10?
Oh you are checking EXPECT_GT I now understand
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.
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.
please also update our documentaion for the command here - https://github.com/dragonflydb/documentation |
Support is added for KEEPTTL to the SAddEx command as described in #4701